1、创建
最大线程数设为Integer.MAX_VALUE,非核心线程空闲时间设置为0。
2、方法
package ThreadPool;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
public class SchedulerThreadPoolTest {
public static int threadId=0;
public static void main(String[] args) {
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
ScheduledThreadPoolExecutor threadPoolExecutor =new ScheduledThreadPoolExecutor(6, new ThreadFactory() {
@Override
public Thread newThread(Runnable r) {
Thread threa