|
@@ -18,7 +18,6 @@ package com.baomidou.mybatisplus.core.toolkit;
|
|
|
import java.sql.Timestamp;
|
|
|
import java.util.concurrent.Executors;
|
|
|
import java.util.concurrent.ScheduledExecutorService;
|
|
|
-import java.util.concurrent.ThreadFactory;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
import java.util.concurrent.atomic.AtomicLong;
|
|
|
|
|
@@ -63,22 +62,12 @@ public class SystemClock {
|
|
|
}
|
|
|
|
|
|
private void scheduleClockUpdating() {
|
|
|
- ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() {
|
|
|
-
|
|
|
- @Override
|
|
|
- public Thread newThread(Runnable runnable) {
|
|
|
- Thread thread = new Thread(runnable, "System Clock");
|
|
|
- thread.setDaemon(true);
|
|
|
- return thread;
|
|
|
- }
|
|
|
+ ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor(runnable -> {
|
|
|
+ Thread thread = new Thread(runnable, "System Clock");
|
|
|
+ thread.setDaemon(true);
|
|
|
+ return thread;
|
|
|
});
|
|
|
- scheduler.scheduleAtFixedRate(new Runnable() {
|
|
|
-
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- now.set(System.currentTimeMillis());
|
|
|
- }
|
|
|
- }, period, period, TimeUnit.MILLISECONDS);
|
|
|
+ scheduler.scheduleAtFixedRate(() -> now.set(System.currentTimeMillis()), period, period, TimeUnit.MILLISECONDS);
|
|
|
}
|
|
|
|
|
|
private long currentTimeMillis() {
|
|
@@ -86,8 +75,6 @@ public class SystemClock {
|
|
|
}
|
|
|
|
|
|
private static class InstanceHolder {
|
|
|
-
|
|
|
public static final SystemClock INSTANCE = new SystemClock(1);
|
|
|
}
|
|
|
-
|
|
|
}
|