Executors

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
 
public class CachedThreadPool {
    public static void main(String[] args) {
       ExecutorService exec = Executors.newCachedThreadPool();
       for (int i = 0; i < 5; i++)
           exec.execute(new MyThread(i));
       exec.shutdown();
    }
}

 

posted @ 2016-03-10 10:28  okay4321  阅读(138)  评论(0编辑  收藏  举报