diff --git a/src/main/java/com/apptasticsoftware/rssreader/AbstractRssReader.java b/src/main/java/com/apptasticsoftware/rssreader/AbstractRssReader.java index 6978f98..1922821 100644 --- a/src/main/java/com/apptasticsoftware/rssreader/AbstractRssReader.java +++ b/src/main/java/com/apptasticsoftware/rssreader/AbstractRssReader.java @@ -24,6 +24,7 @@ package com.apptasticsoftware.rssreader; import com.apptasticsoftware.rssreader.util.Mapper; +import com.apptasticsoftware.rssreader.util.DaemonThreadFactory; import javax.net.ssl.SSLContext; import javax.xml.stream.XMLInputFactory; @@ -64,7 +65,7 @@ */ public abstract class AbstractRssReader { private static final String LOG_GROUP = "com.apptasticsoftware.rssreader"; - private static final ScheduledThreadPoolExecutor EXECUTOR = new ScheduledThreadPoolExecutor(1); + private static final ScheduledExecutorService EXECUTOR = new ScheduledThreadPoolExecutor(1, new DaemonThreadFactory("RssReaderWorker")); private final HttpClient httpClient; private DateTimeParser dateTimeParser = new DateTime(); private String userAgent = ""; diff --git a/src/main/java/com/apptasticsoftware/rssreader/util/DaemonThreadFactory.java b/src/main/java/com/apptasticsoftware/rssreader/util/DaemonThreadFactory.java new file mode 100644 index 0000000..2eba3d4 --- /dev/null +++ b/src/main/java/com/apptasticsoftware/rssreader/util/DaemonThreadFactory.java @@ -0,0 +1,23 @@ +package com.apptasticsoftware.rssreader.util; + +import java.util.concurrent.ThreadFactory; + +/** + * Thread factory that creates daemon threads + */ +public class DaemonThreadFactory implements ThreadFactory { + private final String name; + private int counter; + + public DaemonThreadFactory(String name) { + this.name = name; + } + + @Override + public Thread newThread(Runnable r) { + Thread t = new Thread(r, name + "-" + counter++); + t.setDaemon(true); + return t; + } + +}