ThreadTest.java
908 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package com.dianping.cat.demo;
import org.junit.Test;
import org.unidal.helper.Threads;
import com.dianping.cat.Cat;
import com.dianping.cat.message.Event;
import com.dianping.cat.message.Transaction;
public class ThreadTest {
@Test
public void test() throws InterruptedException {
Transaction t = Cat.newTransaction("test3", "test3");
String id= Cat.getProducer().createMessageId();
Threads.forGroup("cat").start(new Task(id));
Cat.logEvent("RemoteLink", "ChildThread3", Event.SUCCESS, id);
t.complete();
Thread.sleep(1000);
}
public static class Task implements Runnable{
private String m_messageId;
public Task(String id){
m_messageId = id;
}
@Override
public void run() {
Transaction t = Cat.newTransaction("test2", "test2");
Cat.getManager().getThreadLocalMessageTree().setMessageId(m_messageId);
t.complete();
}
}
}