新增云协议相关内容
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
package com.njcn;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.*;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class TestXianCheng {
|
||||
|
||||
|
||||
private static final long AUTO_TIME = 120L;
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
|
||||
Runnable task = () -> {
|
||||
log.info("轮询定时任务执行中!");
|
||||
ExecutorService executor = Executors.newFixedThreadPool(10);
|
||||
// 创建一个ExecutorService来处理这些任务
|
||||
List<Future<Void>> futures = new ArrayList<>();
|
||||
// 提交任务给线程池执行
|
||||
for (int i = 0; i < 10; i++) {
|
||||
int index = i;
|
||||
futures.add(executor.submit(new Callable<Void>() {
|
||||
@Override
|
||||
public Void call() {
|
||||
access();
|
||||
return null;
|
||||
}
|
||||
}));
|
||||
}
|
||||
// 等待所有任务完成
|
||||
for (Future<Void> future : futures) {
|
||||
try {
|
||||
future.get();
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
// 关闭ExecutorService
|
||||
executor.shutdown();
|
||||
};
|
||||
//第一次执行的时间为120s,然后每隔120s执行一次
|
||||
scheduler.scheduleAtFixedRate(task,0,1,TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
|
||||
public static void access() {
|
||||
System.out.println("123");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user