首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2SE开发 >

ThreadPoolExecutor.CallerRunsPolicy()相关有关问题有关问题

2012-06-20 
ThreadPoolExecutor.CallerRunsPolicy()相关问题问题ThreadPoolExecutor threadPool new ThreadPoolExecu

ThreadPoolExecutor.CallerRunsPolicy()相关问题问题
ThreadPoolExecutor threadPool = 
new ThreadPoolExecutor(2, 4,3,TimeUnit.SECONDS, new ArrayBlockingQueue(3),new ThreadPoolExecutor.CallerRunsPolicy());  

我定义的最大线程数是4个,但是为什么会有5个线程启动(先启动2个,然后队列里加3个任务,接下来启动了3个线程)???

[解决办法]

探讨
我就是想问为什么会有五个启动,

下面是我的测试片段:
public class TestThreadPool {

//private static int produceTaskSleepTime = 2;
private static int consumeTaskSleepTime = 2000;
private static int produceTaskMa……

热点排行