首页  

不使用for和while 实现循环效果     所属分类 java 浏览量 479
import java.time.LocalDateTime;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;

public class LoopTaskTest implements Runnable {

	private static final Executor executor = Executors.newFixedThreadPool(1);

	public void run() {
		try {
			Thread.sleep(2000);
			System.out.println(LocalDateTime.now());
		} catch (Throwable e) {
			System.out.println(e);
		} finally {
			// 提交任务 实现循环
			executor.execute(this);
		}
	}

	public static void main(String[] args) throws Exception {
		LoopTaskTest task = new LoopTaskTest();
		executor.execute(task);
	}

}


Timer和ScheduledExecutorService的区别 ScheduledThreadPoolExecutor使用介绍 springBoot定时任务 schedule

上一篇     下一篇
Temporal Clusters

Go检查结构体是否实现了指定接口

temporal worker 线程信息 及 轮询获取工作流关键代码

temporal 多个 worker 实例 测试说明

temporal 工作流注册关键代码

PostgreSQL encode 函数