scheduleAtFixedRate 方法 - 更改 TimeUnit 参数?
scheduleAtFixedRate method - change TimeUnit argument?
我正在使用 SchduledExecuterService class 到 运行 一些重复使用 scheduleAtFixedRate() 方法的代码。
exec.scheduleAtFixedRate(new Runnable() {
public void run() {
//some code
}
}, 1, 1, TimeUnit.SECONDS);
问题是我想根据变量将 TimeUnit 参数更改为秒的某个分数,即 TimeUnit.SECONDS*num;
但是该方法不需要longs作为参数,只需要固定的TimeUnits。有什么建议吗?
你为什么不玩周期参数?
long periodInMicroseconds = 16667;
exec.scheduleAtFixedRate(new Runnable() {
public void run() {
//some code
}
}, 0, periodInMicroseconds, TimeUnit.MICROSECONDS);
我正在使用 SchduledExecuterService class 到 运行 一些重复使用 scheduleAtFixedRate() 方法的代码。
exec.scheduleAtFixedRate(new Runnable() {
public void run() {
//some code
}
}, 1, 1, TimeUnit.SECONDS);
问题是我想根据变量将 TimeUnit 参数更改为秒的某个分数,即 TimeUnit.SECONDS*num; 但是该方法不需要longs作为参数,只需要固定的TimeUnits。有什么建议吗?
你为什么不玩周期参数?
long periodInMicroseconds = 16667;
exec.scheduleAtFixedRate(new Runnable() {
public void run() {
//some code
}
}, 0, periodInMicroseconds, TimeUnit.MICROSECONDS);