package com.wanju.project001.zonghe.test;
import java.util.ArrayList;
import java.util.List;
public class TestThread {
public static List aListSetTest=new ArrayList();
public static void main(String[] args) {
TestThread testThread = new TestThread();
testThread.testThread();
}
public void testThread()
{
aListSetTest.add("eeeeee");
new Thread(new T()).start();
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
new Thread(new T()).start();
}
}
class T implements Runnable{
@Override
public void run() {
synchronized (TestThread.aListSetTest) {
test(this);
}
}
public void test(Runnable t)
{
while(true)
{
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("t"+t.toString());
}
}
}
<pre name="code" class="html">tcom.wanju.project001.zonghe.test.T@1cc2ea3f
tcom.wanju.project001.zonghe.test.T@1cc2ea3f
tcom.wanju.project001.zonghe.test.T@1cc2ea3f
tcom.wanju.project001.zonghe.test.T@1cc2ea3f
tcom.wanju.project001.zonghe.test.T@1cc2ea3f
tcom.wanju.project001.zonghe.test.T@1cc2ea3f
tcom.wanju.project001.zonghe.test.T@1cc2ea3f
tcom.wanju.project001.zonghe.test.T@1cc2ea3f
tcom.wanju.project001.zonghe.test.T@1cc2ea3f