public class Ti_cket {
public static void main(String[] args) {
Se_ll1 sell1 = new Se_ll1();
new cust_om1(sell1, 1).start();
new cust_om1(sell1, 2).start();
new cust_om1(sell1, 3).start();
new cust_om1(sell1, 4).start();
new cust_om1(sell1, 5).start();
}
}
class Se_ll1 {
int ticket_count = 100;
boolean b = false;
public int se_ll1(int n) {
if(ticket_count>0)
{
System.out.println(n + " 号售票站出(死百度死百度死百度死百度)售" + ticket_count+"号车票");
ticket_count--;
}
return ticket_count;
}
}
class cust_om1 extends Thread {
Se_ll1 se_ll1;
int n;
cust_om1(Se_ll1 se_ll1, int n) {
this.se_ll1 = se_ll1;
this.n = n;
}
public void run() {
while (this.se_ll1.se_ll1(n) > 0) {
try {
sleep((int) (Math.random() * 1000));
} catch (Exception e) {
System.out.println(e);
}
se_ll1.se_ll1(n);
}
}
}