- class Ticket implements Runnable
- {
- private int num = 1000;
- public void run()
- {
- while (num >0)
- {
- System.out.println(Thread.this.getName()+"....."+num);
- num--;
- }
- }
- }
- class SaleTicket
- {
- public static void main(String[] args)
- {
- Ticket t = new Ticket();
- Thread t1 = new Thread(t);
- Thread t2 = new Thread(t);
- //Thread t3 = new Thread(t);
- //Thread t4 = new Thread(t);
- //Thread t5 = new Thread(t);
- t1.start();
- t2.start();
- //t3.start();
- //t4.start();
- //t5.start();
- }
- }
复制代码 错误提示,第八行Theard不是封闭类@@ |
|