From def38240262b4403377d4c16beac3ea048f1e658 Mon Sep 17 00:00:00 2001 From: huanghongfa <18228131219@163.com> Date: 星期日, 20 十二月 2020 13:25:39 +0800 Subject: [PATCH] 修改目录结构 --- springcloud_k8s_panzhihuazhihuishequ/auth/src/main/java/com/panzhihua/auth/manager/AsyncManagerNew.java | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 57 insertions(+), 0 deletions(-) diff --git a/springcloud_k8s_panzhihuazhihuishequ/auth/src/main/java/com/panzhihua/auth/manager/AsyncManagerNew.java b/springcloud_k8s_panzhihuazhihuishequ/auth/src/main/java/com/panzhihua/auth/manager/AsyncManagerNew.java new file mode 100644 index 0000000..0e1d9b9 --- /dev/null +++ b/springcloud_k8s_panzhihuazhihuishequ/auth/src/main/java/com/panzhihua/auth/manager/AsyncManagerNew.java @@ -0,0 +1,57 @@ +package com.panzhihua.auth.manager; + +import com.panzhihua.common.utlis.SpringUtils; +import com.panzhihua.common.utlis.Threads; + +import java.util.TimerTask; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; + +/** + * @program: springcloud_k8s_panzhihuazhihuishequ + * @description: 异步任务 + * @author: huang.hongfa weixin hhf9596 qq 959656820 + * @create: 2020-11-20 15:30 + **/ +public class AsyncManagerNew { + + /** + * 操作延迟10毫秒 + */ + private final int OPERATE_DELAY_TIME = 10; + + /** + * 异步操作任务调度线程池 + */ + private ScheduledExecutorService executor = SpringUtils.getBean("scheduledExecutorService"); + + /** + * 单例模式 + */ + private AsyncManagerNew(){} + + private static AsyncManagerNew me = new AsyncManagerNew(); + + public static AsyncManagerNew me() + { + return me; + } + + /** + * 执行任务 + * + * @param task 任务 + */ + public void execute(TimerTask task) + { + executor.schedule(task, OPERATE_DELAY_TIME, TimeUnit.MILLISECONDS); + } + + /** + * 停止任务线程池 + */ + public void shutdown() + { + Threads.shutdownAndAwaitTermination(executor); + } +} -- Gitblit v1.7.1