package test;
/**
* code by miaoXiaoQiang
*/
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
public class TimingTest {
public static void main (String [] args){
// Java接口 java.util.concurrent.ScheduledExecutorService
ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
//以固定的频率执行多线程(FixedRate固定的频率)
//这样线程会以每1000毫秒为单位一直执行下去
executorService.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
System.out.println("run : " + System.currentTimeMillis());
}
}, 0, 1000, TimeUnit.MILLISECONDS);
}
}
/**
* code by miaoXiaoQiang
*/
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
public class TimingTest {
public static void main (String [] args){
// Java接口 java.util.concurrent.ScheduledExecutorService
ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
//以固定的频率执行多线程(FixedRate固定的频率)
//这样线程会以每1000毫秒为单位一直执行下去
executorService.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
System.out.println("run : " + System.currentTimeMillis());
}
}, 0, 1000, TimeUnit.MILLISECONDS);
}
}