class Play {
public static void main(String[] args){
Window w = new Window();
new Thread(w,"窗口1").start();
new Thread(w,"窗口2").start();
new Thread(w,"窗口3").start();
new Thread(w,"窗口4").start();
}
}
class Window implements Runnable {
int a =100;
public void run(){
while (a>=0) {
Thread t = Thread.currentThread();
if (a==10&&!t.getName().equals("窗口3")) {
continue;
}
System.out.println(t.getName()+"还剩"+a-- +"张票");
}
}
}
我是这样做的,,,如果别的窗口来卖第3张票就跳过,,,, |