ThreadPoolExecutor bring performance issues

Use the thread pool, under normal circumstances, it offers performance improvements, and use the thread pool thread management, reduce the cost of calls each task, you can usually provide enhanced performance in the implementation of a large number of asynchronous tasks. But in the case of high concurrency, because of improper use of performance degradation and decline was more severe, let's explain why. ThreadPoolExecutor jdk1.5 version is increased in java.util.concurrent package. Constructor Summary ThreadPoolExecutor (int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue workQueue) individual parameters Description: corePoolSize - the number of threads to keep in the pool, including idle threads. maximumPoolSize - maximum number of threads allowed in the pool. keepAliveTime - when the number of threads is greater than the core, this is terminated before the excess idle threads waiting for new tasks longest time. unit - the time unit keepAliveTime parameters. workQueue - for holding queue before performing the task. In the system design, using ArrayBlockingQueue, prevent system problems caused by the depletion of resources, but the queue in the case of high concurrency, because the thread context switching overhead, resulting in queuing, task frequently blocked, causing the system to serious performance issues.

Guess you like

Origin www.cnblogs.com/zhuitian/p/11248010.html