Skip to content

Commit

Permalink
The default executor service of java.io.concurrent.Future creates dae…
Browse files Browse the repository at this point in the history
…mon threads
  • Loading branch information
smillies committed Sep 14, 2017
1 parent ec2d9b4 commit c0a16a8
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions vavr/src/main/java/io/vavr/concurrent/Future.java
Expand Up @@ -58,10 +58,14 @@
public interface Future<T> extends Value<T> {

/**
* The default executor service is {@link Executors#newCachedThreadPool()}.
* Please note that it may prevent the VM from shutdown.
*/
ExecutorService DEFAULT_EXECUTOR_SERVICE = Executors.newCachedThreadPool();
* The default executor service is {@link Executors#newCachedThreadPool()}. The service will create daemon threads,
* in order to avoid preventing the VM from shutdown.
*/
ExecutorService DEFAULT_EXECUTOR_SERVICE = Executors.newCachedThreadPool(runnable -> {
Thread thread = Executors.defaultThreadFactory().newThread(runnable);
thread.setDaemon(true);
return thread;
});

/**
* Creates a failed {@code Future} with the given {@code exception}, backed by the {@link #DEFAULT_EXECUTOR_SERVICE}.
Expand Down

0 comments on commit c0a16a8

Please sign in to comment.