多线程轮询调用

【多线程轮询调用】创建定时任务每隔一分钟调用一次:
SaticScheduleTask.java

package com.vimochina.vimo.util.Thread; @Configuration//1.主要用于标记配置类,兼备Component的效果。 @EnableScheduling// 2.开启定时任务 public class SaticScheduleTask{ /** * @Description TODO 每个3600毫秒(1分钟) 调用一次 * @CreateBy shp * @CreateTime 2020/6/17 10:47 * @param: * @return void */ @Scheduled(cron = "0/3600 * * * * ?") private void configureTasks() {ExecutorService executor = Executors.newSingleThreadExecutor(); executor.submit(new ThreadTool.Thread1()); executor.submit(new ThreadTool.Thread2()); executor.submit(new ThreadTool.Thread3()); executor.submit(new ThreadTool.Thread4()); executor.submit(new ThreadTool.Thread5()); executor.shutdown(); } }

创建个线程类
package com.vimochina.vimo.util.Thread; public class ThreadTool {public static class Thread1 implements Runnable {@Override public void run() { System.out.println("我是线程1"); }}public static class Thread2 implements Runnable {@Override public void run() { System.out.println("我是线程2"); }}public static class Thread3 implements Runnable {@Override public void run() { System.out.println("我是线程3"); }}public static class Thread4 implements Runnable {@Override public void run() { System.out.println("我是线程4"); }}public static class Thread5 implements Runnable {@Override public void run() { System.out.println("我是线程5"); }}}

然后每隔一分钟就会调用多个线程,并且是安装线程一到线程五这种顺序

    推荐阅读