Java Logo
Java二级在线二级在线
首页选择题程序题成为会员帮助

给线程起个名吧

请修改编辑器中的代码,完成以下功能: 定义一个可以设置名称的线程。程序输出如下: Running the Testing_Thread: ---0---Testing_Thread ---1---Testing_Thread ---2---Testing_Thread ---3---Testing_Thread ---4---Testing_Thread

public  class  Main
{    
   public static void main(String[] args)
   {
      Thread t = new SimpleThread("Testing_Thread");
      ______________  ;   
   }
} 
class SimpleThread extends _________ 
{
   public SimpleThread(String str)
   {
      _____________   ;
   }
   public void _________()
   {  
      System.out.println("Running the " + getName() + ":");
      for (int i = 0; i < 5; i++)
      {
         System.out.println("---" + i + "---" + getName());
         try
         {
            sleep((int)(2 * 100));
         }
         _________(InterruptedException e) { }
      }
   }
}

控制台

调试终端

准备就绪