From ebf3cdc7795a4cfab2ec7bd41f1b25e0b246ca7a Mon Sep 17 00:00:00 2001 From: Mark Payne Date: Wed, 31 Dec 2014 08:45:25 -0500 Subject: [PATCH] NIFI-215: Make the 'detect timing issues' task a daemon --- .../src/main/java/org/apache/nifi/NiFi.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/nar-bundles/framework-bundle/framework/runtime/src/main/java/org/apache/nifi/NiFi.java b/nar-bundles/framework-bundle/framework/runtime/src/main/java/org/apache/nifi/NiFi.java index 98489af16f..ed7c3298dd 100644 --- a/nar-bundles/framework-bundle/framework/runtime/src/main/java/org/apache/nifi/NiFi.java +++ b/nar-bundles/framework-bundle/framework/runtime/src/main/java/org/apache/nifi/NiFi.java @@ -26,6 +26,7 @@ import java.util.TimerTask; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.ThreadFactory; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; @@ -160,7 +161,19 @@ public class NiFi { final int minRequiredOccurrences = 25; final int maxOccurrencesOutOfRange = 15; final AtomicLong lastTriggerMillis = new AtomicLong(System.currentTimeMillis()); - final ScheduledExecutorService service = Executors.newScheduledThreadPool(1); + + final ScheduledExecutorService service = Executors.newScheduledThreadPool(1, new ThreadFactory() { + private final ThreadFactory defaultFactory = Executors.defaultThreadFactory(); + + @Override + public Thread newThread(final Runnable r) { + final Thread t = defaultFactory.newThread(r); + t.setDaemon(true); + t.setName("Detect Timing Issues"); + return t; + } + }); + final AtomicInteger occurrencesOutOfRange = new AtomicInteger(0); final AtomicInteger occurences = new AtomicInteger(0); final Runnable command = new Runnable() {