for 的构造函数具有asThreadPoolExecutor的类型参数。 假设我有一个这样的声明BlockingQueueRunnable
ThreadPoolExecutor
ThreadPoolExecutor customThreadPool = new ThreadPoolExecutor(numberOfAvailableProcessors,
numberOfAvailableProcessors, 2L,
TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<>(),
Executors.defaultThreadFactory(),
new RejectedExecutionHandler() {
@Override
public void rejectedExecution(Runnable r, ThreadPoolExecutor threadPoolExecutor) {
// Do something here to handle it
}
});
我的问题是什么时候做类似的事情:
customThreadPool.submit(new Callable<Integer>() {
@Override
public Integer call() throws Exception {
return Math.toIntExact(Thread.currentThread().getId());
}
})
ThreadPool即使我指定了 to 的类型参数,如何处理Queue这个问题Runnable?
这个任务将如何排队?
鸿蒙传说
相关分类