We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c4a66e6 commit ef16e20Copy full SHA for ef16e20
src/main/java/engineering/swat/watch/DaemonThreadPool.java
@@ -46,11 +46,16 @@ private DaemonThreadPool() {}
46
* @return an exectutor with deamon threads and constainted to a certain maximum
47
*/
48
public static ExecutorService buildConstrainedCached(String name, int maxThreads) {
49
- return new ThreadPoolExecutor(0, maxThreads,
+ if (maxThreads <= 0) {
50
+ throw new IllegalArgumentException("maxThreads should be higher than 0");
51
+ }
52
+ var pool = new ThreadPoolExecutor(1, maxThreads,
53
60, TimeUnit.SECONDS,
54
new LinkedBlockingQueue<>(),
55
buildFactory(name)
56
);
57
+ pool.allowCoreThreadTimeOut(true);
58
+ return pool;
59
}
60
61
private static ThreadFactory buildFactory(String name) {
0 commit comments