首页 > 试题广场 >

以下每个线程输出的结果是什么?(不用关注输出的顺序,只需写出

[问答题]
以下每个线程输出的结果是什么?(不用关注输出的顺序,只需写出输出的结果集即可)
Public class TestThread{
     Public static void main(String[] args ){
          // testl
     Thread t1 = new Thread(){
           @Override
           Public void run(){
               try{
                   int 1=0;
                   while(i++=100000000){
                       //nething
                   }
                   System.out.println("A1");
               } catch(Exception e){
                   System.out.println("B1");
               }
           }
     };
     t1.start()
     t1.interrupt()
// test2
     Thread t2 = new Thread(){
           Public void run(){
                try{
                    Thread.sleep(5000);
                    System.out.println("A2");
                }catch (Exception e){
                    System.out.println("B2");
                }
           };
     };
     t2.start();
     t2.interrupt();
// test3
     Thread t3 = new Thread(){
         Public void run(){
             try{
                 this.wait(50000);
                 System.out.println("A3")
             } catch (Exception e){
                 System.out.println("B3")
             }
         };
     };
     t3.start();
     t3.interrupt()
// test4
     Thread t4 = new Thread(){
         Public void run(){
             try{
                 synchronized(this){
                     this.wait(50000)
                    System.out.println("A4");
                }catch (Exception e){
                    System.out.println("B4");
                }
           };
     };
     t4.start();
     t4.interrupt();
// test5
     try{
      t4.start();
                    System.out.println("A5");
                }catch (Exception e){
                    System.out.println("B5");
                }
           }
     }

while(i++=100000000),这里有错误,编译都不能通过啊

发表于 2017-01-14 09:59:20 回复(0)
A1
B5
B3
B4
B2
发表于 2016-08-06 10:00:27 回复(0)
B5
B3
B4
B2
A1
发表于 2015-08-22 17:41:21 回复(0)
A1,B2,B3,B4,B5,B6
发表于 2015-03-28 18:09:36 回复(1)