Java 二级操作题 创建两个线程 并输出名字

public class Java_1
{
   //*********Found**********
   public  static  void main (String args[])
   {
      new SimpleThread("х┌1").start();
      new SimpleThread("х┌2").start();
   }

//*********Found**********
class SimpleThread extends Thread
{
   public SimpleThread(String str)
   {
      super(str);
   }
   public void run()
   {
      for (int i = 0; i < 5; i++)
      {
   //*********Found**********
         System.out.println(i + " " + getName());
         try
         {
            sleep((int)(2 * 100));
         }
         catch (InterruptedException e) { }
      }
      System.out.println("н╦лл! " + getName());
   }
}

猜你喜欢

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