class Test implements Runnable {
public synchronized void run() {
while (true) {
System.out.println(Thread.currentThread().getName() + ".....");
}
}
}
public class TestDemo {
public static void main(String[] args) {
Test t = new Test();
Thread t1 = new Thread(t);
Thread t2 = new Thread(t);
t1.start();
t2.start();
//为什么只看到0号线程了。。。
}
}
|