class xx implements Runnable {
        
         public void run() {
            for(int i=0;i<10;i++)
   {
            System.out.println("fff");
   }
         }
     }当里面循环完毕时候,这个线程会自动销毁吗?或被回收资源?
如果用eclipse执行好像一直是运行状态,如果加入excutorservice里,在执行shoudown就关掉了。

解决方案 »

  1.   

    public class Test implements Runnable {
        public static void main(final String[] args) {
            new Thread(new Test()).start();
        }    @Override public void run() {
            for (int i = 0; i < 10; i++) {
                System.out.println("fff");
            }
        }
    }
    自动完事