public class Sa {
public static void main(String[] args) {
ThreadSellTciket sTicket=new ThreadSellTciket(); //创建属于类ThreadSellTciket的对象sTicket
new Thread(sTicket).start(); //创建3个同优先级的线程
new Thread(sTicket).start();
new Thread(sTicket).start();
}
}
class ThreadSellTciket implements Runnable{ //创建类ThreadSellTciket,实现接口Runnable
private int tickets=10;
boolean flag=true;
public void run(){
public static void main(String[] args) {
ThreadSellTciket sTicket=new ThreadSellTciket(); //创建属于类ThreadSellTciket的对象sTicket
new Thread(sTicket).start(); //创建3个同优先级的线程
new Thread(sTicket).start();
new Thread(sTicket).start();
}
}
class ThreadSellTciket implements Runnable{ //创建类ThreadSellTciket,实现接口Runnable
private int tickets=10;
boolean flag=true;
public void run(){