日期:2014-05-20 浏览次数:20746 次
package multhread;
public class SynThreadTest extends Thread {
public static int count = 1;
public synchronized void run()
{
// synchronized(this)
{
for(int i=0;i<10;i++)
System.out.println(" " + i);
}
}
public static void main(String[] args)
{
SynThreadTest test1 = new SynThreadTest();
SynThreadTest test2 = new SynThreadTest();
Thread t1 = new Thread(test1,"test1");
Thread t2 = new Thread(test2,"test2");
t1.start();
t2.start();
// test1.start();
// test2.start();
}
}