本帖最后由 郭军亮 于 2013-5-15 14:13 编辑
- package xuexi1;
- public class ThreadDemo {
- /**
- * @param args
- * @throws InterruptedException
- */
- public static void main(String[] args) throws InterruptedException {
- // TODO Auto-generated method stub
- ticket t1=new ticket();
- ticket t2=new ticket();
- ticket t3=new ticket();
- ticket t4=new ticket();
- t1.start();
- t1.sleep(10);
- t2.start();
- t3.start();
- t4.start();
- }
- }
- class ticket extends Thread{
- private static int tic =100;
- @Override
- public void run(){
- while(true){
-
- if(tic>0)
- System.out.println(Thread.currentThread().getName()+"....."+tic--);
- }
- }
- }
复制代码 想问一下为什么每次执行完以后 dos命令行不会自动结束,而必须用Ctrl+c来结束啊??? |