From 23ca592b1ef9b0d5122af1c582ccdad992a837ae Mon Sep 17 00:00:00 2001 From: linwl <304115325@qq.com> Date: Thu, 25 Feb 2021 12:07:36 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A1=E6=95=B0=E7=BA=BF=E7=A8=8B=E5=A4=84?= =?UTF-8?q?=E7=90=86=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iotgateway/listener/IotMessageListener.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/telpo/iotgateway/listener/IotMessageListener.java b/src/main/java/com/telpo/iotgateway/listener/IotMessageListener.java index 976f7e2..ef360ae 100644 --- a/src/main/java/com/telpo/iotgateway/listener/IotMessageListener.java +++ b/src/main/java/com/telpo/iotgateway/listener/IotMessageListener.java @@ -26,6 +26,13 @@ public class IotMessageListener implements MessageListener { private Runnable runnable; public IotMessageListener() { + + } + + private ExecutorService executorService; + public void setExecutorService(ExecutorService executorService) { + + this.executorService = executorService; this.runnable = new Runnable() { //创建 run 方法 @Override @@ -43,12 +50,7 @@ public class IotMessageListener implements MessageListener { // 第二个参数为首次执行的延时时间,第三个参数为定时执行的间隔时间 // 10:秒 5:秒 // 第一次执行的时间为10秒,然后每隔五秒执行一次 - service.scheduleAtFixedRate(runnable, 30, 60, TimeUnit.SECONDS); - } - - private ExecutorService executorService; - public void setExecutorService(ExecutorService executorService) { - this.executorService = executorService; + service.scheduleAtFixedRate(runnable, 90, 60, TimeUnit.SECONDS); } @Override