Skip to content

Commit

Permalink
Merge pull request #1630 from Skyllarr/ELY-2195
Browse files Browse the repository at this point in the history
[ELY-2195] Use daemon threads in default ScheduledExecutorService
  • Loading branch information
darranl committed Dec 8, 2021
2 parents fb5cef7 + b95bc55 commit 017ccf4
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.function.Consumer;
Expand Down Expand Up @@ -1242,7 +1243,12 @@ private void assertNotBuilt() {

private static class ScheduledExecutorServiceProvider {

private static final ScheduledThreadPoolExecutor INSTANCE = new ScheduledThreadPoolExecutor(1);
private static final ScheduledThreadPoolExecutor INSTANCE = new ScheduledThreadPoolExecutor(1, runnable -> {
// use daemon thread
Thread thread = Executors.defaultThreadFactory().newThread(runnable);
thread.setDaemon(true);
return thread;
});

static {
INSTANCE.setRemoveOnCancelPolicy(true);
Expand Down

0 comments on commit 017ccf4

Please sign in to comment.