倾尽技术分相问:为什么这两段代码输出不一样?为什么?
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();
}
}