public void run() {
synchronized (lock) {
while (true) {
if(num>0){
System.out.println(Thread.currentThread().getName() + "要卖第" + num + "张票");
num--;
} } } }
SealWindow sealWindow = new SealWindow();
Thread t1= new Thread(sealWindow,"窗口1");
Thread t2= new Thread(sealWindow,"窗口2");
t1.start();
t2.start();
我写的这段代码为什么只有t1运行,线程t2没运行
|
|