ThreadDebugger icon indicating copy to clipboard operation
ThreadDebugger copied to clipboard

newExceedCallerRunsPool newExceedCallImmediatelyPool 场景区别

Open ronanhardiman opened this issue 9 years ago • 1 comments

库写的很好,学习了,请教下 newExceedCallerRunsPool newExceedCallImmediatelyPool 的使用场景区别, 看了文档,还没很明白,谢谢。

ronanhardiman avatar Sep 29 '16 13:09 ronanhardiman

谢谢。

  • newExceedCallerRunsPool:当运行中的任务达到maximumPoolSize个数,还有任务进入线程池的时候,会立即在调用进入线程池方法的线程执行(execute/submit)。
  • newExceedCallImmediatelyPool:当运行中的任务达到maximumPoolSize个数,还有任务进入线程池的时候,会立即在一个全局的RealExecutors.TEMPORARY_CACHED_THREAD_POOL线程池(该线程池中的线程在闲置5秒后就会直接释放)中执行。

库中的newExceedWaitPool目前在任务高并发进出队列的时候,由于ThreadPoolExecutor#getActiveCount 返回的个数并不一定准确,小概率会出现StackOverflowError的bug,我正在想办法解决这个问题,也欢迎PR。

Jacksgong avatar Sep 29 '16 14:09 Jacksgong