黑马程序员技术交流社区

标题: 多线程提问。 [打印本页]

作者: LLLLL    时间: 2015-8-25 19:38
标题: 多线程提问。
class  ThreadTest
{
         public static void main(String[] args)
         {
                 new Thread()
                 {
                         public void run()
                         {
                                 for (int x=0;x<=40 ;x++ )
                                 {
                                         System.out.println(Thread.currentThread().getName()+"----"+x);
                                 }
                         }        
                 }.start();
                 for (int x=0;x<=40 ;x++ )
                 {
                         System.out.println(Thread.currentThread().getName()+"----"+x);
                 }
                 Thread t=new Thread()
                 {
                         public void run()
                         {
                                 for (int x=0;x<=40 ;x++ )
                                 {
                                         System.out.println(Thread.currentThread().getName()+"----"+x);
                                 }
                         }
                 };
                 t.start();
         }
}

为什么t.start( ) ;要等他俩结束才运行
作者: sven556677    时间: 2015-8-25 20:33
程序按顺序执行?




欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2