JSON requests threads may be terminated in middle without any problems classloader
authorJaroslav Tulach <jaroslav.tulach@apidesign.org>
Tue, 25 Jun 2013 12:37:31 +0200
branchclassloader
changeset 158659a5452a432
parent 157 b2e448adfa59
child 159 ceac58dd82a1
JSON requests threads may be terminated in middle without any problems
ko-fx/src/main/java/org/apidesign/html/kofx/LoadJSON.java
     1.1 --- a/ko-fx/src/main/java/org/apidesign/html/kofx/LoadJSON.java	Tue Jun 25 12:18:12 2013 +0200
     1.2 +++ b/ko-fx/src/main/java/org/apidesign/html/kofx/LoadJSON.java	Tue Jun 25 12:37:31 2013 +0200
     1.3 @@ -33,6 +33,7 @@
     1.4  import java.util.Iterator;
     1.5  import java.util.concurrent.Executor;
     1.6  import java.util.concurrent.Executors;
     1.7 +import java.util.concurrent.ThreadFactory;
     1.8  import java.util.logging.Level;
     1.9  import java.util.logging.Logger;
    1.10  import javafx.application.Platform;
    1.11 @@ -52,7 +53,14 @@
    1.12   */
    1.13  final class LoadJSON implements Runnable {
    1.14      private static final Logger LOG = FXContext.LOG;
    1.15 -    private static final Executor REQ = Executors.newCachedThreadPool();
    1.16 +    private static final Executor REQ = Executors.newCachedThreadPool(new ThreadFactory() {
    1.17 +        @Override
    1.18 +        public Thread newThread(Runnable runnable) {
    1.19 +            Thread thread = Executors.defaultThreadFactory().newThread(runnable);
    1.20 +            thread.setDaemon(true);
    1.21 +            return thread;
    1.22 +        }
    1.23 +    });
    1.24  
    1.25      private final JSONCall call;
    1.26      private final URL base;