1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
class Ticket extends Thread { private String name; Ticket(String name){ this.name=name; }
private static int tick=100; public void run() { synchronized (this) {
while (true) { if (tick > 0) { System.out.println(name + "卖了:--" + tick--); } } } }
}
|
近期评论