Browse Source

计数线程处理调整

master
林万龙 3 years ago
parent
commit
23ca592b1e
1 changed files with 8 additions and 6 deletions
  1. +8
    -6
      src/main/java/com/telpo/iotgateway/listener/IotMessageListener.java

+ 8
- 6
src/main/java/com/telpo/iotgateway/listener/IotMessageListener.java View File

@@ -26,6 +26,13 @@ public class IotMessageListener implements MessageListener {
private Runnable runnable; private Runnable runnable;


public IotMessageListener() { public IotMessageListener() {

}

private ExecutorService executorService;
public void setExecutorService(ExecutorService executorService) {

this.executorService = executorService;
this.runnable = new Runnable() { this.runnable = new Runnable() {
//创建 run 方法 //创建 run 方法
@Override @Override
@@ -43,12 +50,7 @@ public class IotMessageListener implements MessageListener {
// 第二个参数为首次执行的延时时间,第三个参数为定时执行的间隔时间 // 第二个参数为首次执行的延时时间,第三个参数为定时执行的间隔时间
// 10:秒 5:秒 // 10:秒 5:秒
// 第一次执行的时间为10秒,然后每隔五秒执行一次 // 第一次执行的时间为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 @Override


Loading…
Cancel
Save