import java.util.concurrent.executorservice;import java.util.concurrent.executors;/** * One of the simplest thread pools, this model is simple, but useful * * @author leizhimin 2014/8/22 20:21 */public class Test3 { private static final ExecutorService Threadpool = executors.newfixedthreadpool (1); public static void main (String[] args) throws InterruptedException { for (int i = 0; i < 10000; i++) { final int finalI = i; Runnable r = new Runnable () { @Override &nbsP; public void run () { system.out.println (string.valueof (Finali) + ":" +system.currenttimemillis ()); } }; Threadpool.submit (R); Thread.CurrentThread (). Sleep (300L); } }}
0:14091870824551:14091870827552:14091870830553:14091870833554:14091870836555:14091870839556:14091870842557:14091870845558 : 14091870848559:140918708515510:140918708545511:1409187085755 ...
This article is from the lava blog, so be sure to keep this source http://lavasoft.blog.51cto.com/62575/1545968
One of the simplest thread pools