- class Ticket extends Thread
- {
- private static int tick=100;
- private String name;
- Ticket(String name)
- {
- this.name=name;
- }
- public void run()
- {
- while(true)
- {
- if(tick>0)
- {
- tick--;
- System.out.println(Thread.currentThread().getName()+"Run"+tick);
- }
- }
- }
- }
- class ThreadDemo
- {
- public static void main(String[] args)
- {
- Ticket t1=new Ticket("one");
- Ticket t2=new Ticket("two");
- t2.start();
- t1.start();
- }
- }
复制代码
运行后结果出来了,但是为什么对话框卡在那,不能继续输入了? |
|