本帖最后由 HelloWorld90 于 2012-06-12 18:46:57 编辑

解决方案 »

  1.   

    写一个子类继承Thread类,是为了重写里面的run()方法,也就是线程启动后真正执行的内容。
    如果你直接Thread thread = new Thread();创建对象,语法上没有错的,但是run()方法是系统默认的,也不是你自己想定义的线程中的方法,那这个线程有什么意义呢?
      

  2.   


        /**
         * If this thread was constructed using a separate 
         * <code>Runnable</code> run object, then that 
         * <code>Runnable</code> object's <code>run</code> method is called; 
         * otherwise, this method does nothing and returns. 
         * <p>
         * Subclasses of <code>Thread</code> should override this method. 
         *
         * @see     #start()
         * @see     #stop()
         * @see     #Thread(ThreadGroup, Runnable, String)
         */
        public void run() {
    if (target != null) {
        target.run();
    }
        }这是jdk中Thread类run()方法的源码,一般自己写线程都要重定义覆盖这个方法吧,它默认的方法很难满足需求
      

  3.   

    创建java线程只有一种方法唯一的方法就是创建一个Thread或其子类的对象,并调用其start方法,没调用start方法就没有创建线程,只是一个普通对象每个java线程都与一个Thread对象相关联