装女人欺骗别人。你认为我们会上当么?打死也不回答

解决方案 »

  1.   

    哎,入门的书上就有现成的代码,
      

  2.   

    楼上的牛
    准备怎么顶法???
      

  3.   

    想怎么顶,就怎么顶!!直到问题解决为止
      

  4.   

    /*请编写一个类,类名为subThread ,它是Thread 类的子类。该类中定义了含一个字符串参数的构造函数和run( )方法,方法中有一个for循环,循环一共进行5次,循环体中先在命令行显示该线程循环到了第几次,然后随机休眠小于1秒的时间,循环结束后显示线程结束信息: 线程名+"finished"。编写Application,在其中创建subThread类的三个对象t1、t2、t3,它们的名称分别为"First"、"Second"、"Third",并启动这三个线程。*/
    public class useSub{
      public static void main(String args[]){
          subThread t1=new subThread();
          subThread t2=new subThread();
          subThread t3=new subThread();      t1.start(First);
          t2.start(Second);
          t3.start(Third);  }
    }
    class subThread extends Thread
    {
      public void run(String str){
         for(int times=0;times<5;times++){
          System.out.println("thread:"+str+"reached the"+times+"times");
          try{
               Thread.sleep(500);
              }
          catch(InterruptedException e){
              System.exit(1);
           }       
      }
         System.out.println(str+"finished");
     }
    }
      

  5.   

    刚刚写的,应该没有问题要是行的话,要记得加分啊!!!!!