Principle thread pool analysis

1. Why do you want to create a thread pool?

  In order to avoid frequent create threads of the system resource overhead

  By controlling the size of the thread to the thread pool to achieve the effect of limiting

2. quickly build thread pool

ExecutorService executorService1=Executors.newSingleThreadExecutor();
ExecutorService executorService2=Executors.newFixedThreadPool(2);
ExecutorService executorService3=Executors.newCachedThreadPool();
ExecutorService executorService4=Executors.newScheduledThreadPool();

 

Guess you like

Origin www.cnblogs.com/wongandy/p/11260643.html