package com.threadPool.executiveService;
public class MyThread implements Runnable{
@Override
public void run() {
for(int i=0; i<100; i++) {
System.out.println(Thread.currentThread().getName() + "i = " + i);
}
}
}
package com.threadPool.executiveService;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class ThreadPoolTest {
public static void main(String[] args) {
ExecutorService threadPool = Executors.newFixedThreadPool(6);
threadPool.submit(new MyThread());
threadPool.submit(new MyThread());
threadPool.submit(new MyThread());
threadPool.shutdown();
}
}