One of the simplest thread pools

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.