日期:2014-05-20 浏览次数:20882 次
import java.util.*;
public class Testinterrupt
{
      public static void main(String [] args)
      {
        MyRun r = new MyRun();
        Thread t = new Thread(r);
        t.start();
      
        try
        {
              t.sleep(10000);
        }
        catch(InterruptedException e)
        {
            
        }
        t.interrupt();
        
      }
}
class MyRun implements Runnable
{
      public void run()
      {
           while(true)
           {
                  System.out.println("====="+new Date()+"========");
                  try 
                  {
                         sleep(1000);
                      }
                      catch(InterruptedException e)
                      {
                          return;
                      }
               }
      }
}