当前位置:网站首页>Solve high and send system Currenttimemillis Caton
Solve high and send system Currenttimemillis Caton
2022-07-03 03:12:00 【Friendship years】
public class SystemClock {
private final int period;
private final AtomicLong now;
private static class InstanceHolder {
private static final SystemClock INSTANCE = new SystemClock(1);
}
private SystemClock(int period) {
this.period = period;
this.now = new AtomicLong(System.currentTimeMillis());
scheduleClockUpdating();
}
private static SystemClock instance() {
return InstanceHolder.INSTANCE;
}
private void scheduleClockUpdating() {
ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor(runnable -> {
Thread thread = new Thread(runnable, "System Clock");
thread.setDaemon(true);
return thread;
});
scheduler.scheduleAtFixedRate(() -> now.set(System.currentTimeMillis()), period, period, TimeUnit.MILLISECONDS);
}
private long currentTimeMillis() {
return now.get();
}
/**
* To replace the original System.currentTimeMillis()
*/
public static long now() {
return instance().currentTimeMillis();
}
边栏推荐
- Le processus de connexion mysql avec docker
- Getting started | jetpack hilt dependency injection framework
- 力扣------网格中的最小路径代价
- Vs Code configure virtual environment
- MySql实战45讲【SQL查询和更新执行流程】
- Privatization lightweight continuous integration deployment scheme -- 01 environment configuration (Part 2)
- How to select the minimum and maximum values of columns in the data table- How to select min and max values of a column in a datatable?
- MySql实战45讲【全局锁和表锁】
- I2C 子系统(一):I2C spec
- Force deduction ----- the minimum path cost in the grid
猜你喜欢

Kubernetes family container housekeeper pod online Q & A?

力扣------网格中的最小路径代价

Agile certification (professional scrum Master) simulation exercise-2

3D drawing example

Idea format code idea set shortcut key format code

MySql實戰45講【SQL查詢和更新執行流程】

敏捷认证(Professional Scrum Master)模拟练习题-2

docker安装redis
![MySQL practice 45 lecture [transaction isolation]](/img/a5/5420651d6be51e892976f02be8c43c.png)
MySQL practice 45 lecture [transaction isolation]

Nasvit: neural architecture search of efficient visual converter with gradient conflict perception hypernetwork training
随机推荐
VS 2019安装及配置opencv
Use optimization | points that can be optimized in recyclerview
Idea set method call ignore case
idea 加载不了应用市场解决办法(亲测)
How to use asp Net MVC identity 2 change password authentication- How To Change Password Validation in ASP. Net MVC Identity 2?
Vs 2019 configure tensorrt to generate engine
The process of connecting MySQL with docker
Introduction to cron expression
Agile certification (professional scrum Master) simulation exercises
docker安装redis
左连接,内连接
Can netstat still play like this?
The idea cannot be loaded, and the market solution can be applied (pro test)
I2C subsystem (I): I2C spec
Deep reinforcement learning for intelligent transportation systems: a survey paper reading notes
Parameter index out of range (1 > number of parameters, which is 0)
Force deduction ----- the minimum path cost in the grid
【PyG】理解MessagePassing过程,GCN demo详解
Change cell color in Excel using C - cell color changing in Excel using C
PHP constructor with parameters - PHP constructor with a parameter