- public class Test_7 implements Runnable{
 
  
-         public static void main(String[] args) {
 
 -                 Test_7 t7=new Test_7();
 
 -                 Thread t7t=new Thread(t7);
 
 -                 t7t.start();
 
 -                 try{
 
 -                         Thread.sleep(2000);
 
 -                 }
 
 -                 catch(InterruptedException e){}
 
 -                 System.out.println("In the main(),interrupt the other thread !");
 
 -                 t7t.interrupt();
 
 -                 System.out.println("In the main(),quit !");
 
 -         }
 
 -         public void run(){
 
 -                 try{
 
 -                         System.out.println("In the run(),this thread sleep 20S !");
 
 -                         Thread.sleep(20000);
 
 -                         System.out.println("In the run(),this thread is go on !");
 
 -                 }
 
 -                 catch(InterruptedException e){
 
 -                         System.out.println("In the run(),this thread is interrupted !");
 
 -                         return;
 
 -                 }
 
 -                 System.out.println("In the run(),this thread is go to finish !");
 
 -                 System.out.println("In the run(),this thread quit in normal !");
 
 -         }
 
 - }
 
  复制代码 
书上的结果是: 
In the run(),this thread sleep 20S ! 
In the main(),interrupt the other thread ! 
In the run(),this thread is interrupted ! 
In the main(),quit ! 
 
我的结果是: 
In the run(),this thread sleep 20S ! 
In the main(),interrupt the other thread ! 
In the main(),quit ! 
In the run(),this thread is interrupted ! |   
        
 
    
    
    
     
 
 |