猿问

是否有使用当前线程的ExecutorService?

是否有使用当前线程的ExecutorService?

我所追求的是一种配置线程池使用的兼容方式。理想情况下,其余代码不应受到影响。我可以使用一个线程池与1个线程,但这不是我想要的。有任何想法吗?

ExecutorService es = threads == 0 ? new CurrentThreadExecutor() : Executors.newThreadPoolExecutor(threads);// es.execute / es.submit / new ExecutorCompletionService(es) etc


慕田峪4524236
浏览 490回答 3
3回答

月关宝盒

Java 8风格:Executor e = Runnable::run;
随时随地看视频慕课网APP

相关分类

Java
我要回答