按照常规思路,如下:
public class Test02 {
public static void main(String[] args) {
SellTicket sellTicket=new SellTicket();
Thread thread1=new Thread(sellTicket,"窗口一");
Thread thread2=new Thread(sellTicket,"窗口二");
Thread thread3=new Thread(sellTicket,"窗口三");
thread1.start();
thread2.start();
thread3.start();
}
}
public class SellTicket implements Runnable {
private static int tickets=100;
boolean flag=true;
int i=1;
@Override
public void run() {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e