Skip to content

Commit ae53199

Browse files
committed
Move DaemonThreadFactory into DScheduledTask and simplify
1 parent fa81736 commit ae53199

File tree

2 files changed

+17
-38
lines changed

2 files changed

+17
-38
lines changed

metrics/src/main/java/io/avaje/metrics/DScheduledTask.java

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
import io.avaje.applog.AppLog;
44

55
import java.util.Objects;
6-
import java.util.concurrent.Executors;
7-
import java.util.concurrent.ScheduledExecutorService;
8-
import java.util.concurrent.ScheduledFuture;
9-
import java.util.concurrent.TimeUnit;
6+
import java.util.concurrent.*;
107
import java.util.concurrent.locks.ReentrantLock;
118

129
import static java.lang.System.Logger.Level.ERROR;
@@ -96,4 +93,20 @@ private void runTask() {
9693
activeLock.unlock();
9794
}
9895
}
96+
97+
private static final class DaemonThreadFactory implements ThreadFactory {
98+
99+
private final String name;
100+
101+
DaemonThreadFactory(String name) {
102+
this.name = name;
103+
}
104+
105+
@Override
106+
public Thread newThread(Runnable r) {
107+
Thread t = new Thread(r, name);
108+
t.setDaemon(true);
109+
return t;
110+
}
111+
}
99112
}

metrics/src/main/java/io/avaje/metrics/DaemonThreadFactory.java

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)