Package COM. lesson. threadpool. example; import Java. util. concurrent. executorservice; import Java. util. concurrent. executors; import Java. util. concurrent. timeunit; public class threadpooltest {public static void main (string [] ARGs) {// create three thread pools executorservice threadpool =
Executors. newfixedthreadpool (3); // executors. newcachedthreadpool (); For (INT I = 1; I <= 10; I ++) {final int task = imo-threadpool.exe cute (New runnable () {public void run () {//.. for (Int J = 1; j <= 10; j ++) {try {thread. sleep (20);} catch (interruptedexception e) {// todo auto-generated catch blocke. printstacktrace ();} system. out. println (thread. currentthread (). getname () + "is loop of" + J +" Task
"+ Task) ;}}}) ;}system. out. println ("all of 10 tasks have committed"); // threadpool. shutdown (); // shutdownnow ();//.... executors. newscheduledthreadpool (3 ). scheduleatfixedrate (New
Runnable () {public void run () {system. Out. println ("Bombing") ;}, 6, 2, timeunit. Seconds );}}