diff --git a/hippo4j-core/src/main/java/cn/hippo4j/core/toolkit/SystemClock.java b/hippo4j-core/src/main/java/cn/hippo4j/core/toolkit/SystemClock.java index 96283d87..2e0c15b4 100644 --- a/hippo4j-core/src/main/java/cn/hippo4j/core/toolkit/SystemClock.java +++ b/hippo4j-core/src/main/java/cn/hippo4j/core/toolkit/SystemClock.java @@ -1,7 +1,6 @@ package cn.hippo4j.core.toolkit; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; @@ -16,6 +15,8 @@ public class SystemClock { private final AtomicLong now; + private static final String THREAD_NAME ="system.clock"; + private static class InstanceHolder { private static final SystemClock INSTANCE = new SystemClock(1); } @@ -31,8 +32,8 @@ public class SystemClock { } private void scheduleClockUpdating() { - ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor(runnable -> { - Thread thread = new Thread(runnable, "System Clock"); + ScheduledThreadPoolExecutor scheduler = new ScheduledThreadPoolExecutor(1, r -> { + Thread thread = new Thread(r, THREAD_NAME); thread.setDaemon(true); return thread; });