Java二级操作题 输出线程名称2

public  class  Java_2
{    
   public static void main(String[] args)
   {
      Thread t = new SimpleThread("Testing_Thread");
       //*********Found**********
      t.start();   
   }

 //*********Found**********
class SimpleThread extends Thread
{
   public SimpleThread(String str)
   {
      //*********Found**********
       setName(str);
   }
    //*********Found**********
   public void run()
   {  
      System.out.println("Running the " + getName() + ":");
      for (int i = 0; i < 5; i++)
      {
         System.out.println("---" + i + "---" + getName());
         try
         {
            sleep((int)(2 * 100));
         }
         //*********Found**********
         catch(InterruptedException e) { }
      }
   }
}
 

猜你喜欢

转载自blog.csdn.net/qq_38945163/article/details/81355371