I am a beginner java programmer and i saw a code on internet about my projet. But i didn't understand what it does ? Anyone can explain ? What are 1000s ?
我是初学Java程序员,我在互联网上看到了关于我的项目的代码。但我不明白它的作用?谁能解释一下?什么是1000?
private Timer timer = null;
private int timeWorking;
private void xxxxxxxxxxx() {
if (timer == null) {
timer = new Timer("Time");
timer.schedule(new TimerTask() {
@Override
public void run() {
timeWorking++;
}
}, 1000, 1000);
}
}
4 个解决方案
#1
This is a call to java.util.Timer.schedule(TimerTask task, long delay, long period)
:
这是对java.util.Timer.schedule的调用(TimerTask任务,长延迟,长周期):
Schedules the specified task for repeated fixed-delay execution, beginning after the specified delay.
在指定的延迟之后开始,为重复的固定延迟执行安排指定的任务。
Both delay
and period
are in milliseconds. 1000 milliseconds are equal to one second.
延迟和周期都以毫秒为单位。 1000毫秒等于一秒。
#2
The see documentation of Timer.schedule()
参见Timer.schedule()的文档
task - task to be scheduled.delay -
delay in milliseconds before task is to be executed.period -
time in milliseconds between successive task executions.
#3
See java.util.Timer documentation
请参阅java.util.Timer文档
The first "1000" means delay - delay in milliseconds before task is to be executed. The second "1000" means period - time in milliseconds between successive task executions.
第一个“1000”表示延迟 - 在执行任务之前以毫秒为单位的延迟。第二个“1000”表示连续任务执行之间的时间段(以毫秒为单位)。
#4
public void schedule(TimerTask task, long delay, long period) you are calling this method with delay 1000ms and period 1000ms.
public void schedule(TimerTask任务,长延迟,长时间段)您正在调用此方法,延迟时间为1000毫秒,时间段为1000毫秒。
#1
This is a call to java.util.Timer.schedule(TimerTask task, long delay, long period)
:
这是对java.util.Timer.schedule的调用(TimerTask任务,长延迟,长周期):
Schedules the specified task for repeated fixed-delay execution, beginning after the specified delay.
在指定的延迟之后开始,为重复的固定延迟执行安排指定的任务。
Both delay
and period
are in milliseconds. 1000 milliseconds are equal to one second.
延迟和周期都以毫秒为单位。 1000毫秒等于一秒。
#2
The see documentation of Timer.schedule()
参见Timer.schedule()的文档
task - task to be scheduled.delay -
delay in milliseconds before task is to be executed.period -
time in milliseconds between successive task executions.
#3
See java.util.Timer documentation
请参阅java.util.Timer文档
The first "1000" means delay - delay in milliseconds before task is to be executed. The second "1000" means period - time in milliseconds between successive task executions.
第一个“1000”表示延迟 - 在执行任务之前以毫秒为单位的延迟。第二个“1000”表示连续任务执行之间的时间段(以毫秒为单位)。
#4
public void schedule(TimerTask task, long delay, long period) you are calling this method with delay 1000ms and period 1000ms.
public void schedule(TimerTask任务,长延迟,长时间段)您正在调用此方法,延迟时间为1000毫秒,时间段为1000毫秒。