admin
2025-02-25 30d8e227e8d823b6c38c3b9c90ac2df03b63befe
fanli/src/main/java/com/yeshi/fanli/util/ThreadUtil.java
@@ -1,26 +1,26 @@
package com.yeshi.fanli.util;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
/**
 * 线程池工具
 * @author cxx
 *
 * @date 2018年1月29日
 */
public class ThreadUtil {
   private static LinkedBlockingQueue<Runnable> queue=new LinkedBlockingQueue<Runnable>(100);
   private static ThreadPoolExecutor threadPoolExecutor=new ThreadPoolExecutor(30, 3000, 20, TimeUnit.SECONDS, queue);
   static{
      threadPoolExecutor.allowCoreThreadTimeOut(true);
   }
   public static void run(Runnable runnable){
      threadPoolExecutor.execute(runnable);
   }
}
package com.yeshi.fanli.util;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
/**
 * 线程池工具
 * @author cxx
 *
 * @date 2018年1月29日
 */
public class ThreadUtil {
   private static LinkedBlockingQueue<Runnable> queue=new LinkedBlockingQueue<Runnable>(100);
   private static ThreadPoolExecutor threadPoolExecutor=new ThreadPoolExecutor(30, 3000, 20, TimeUnit.SECONDS, queue);
   static{
      threadPoolExecutor.allowCoreThreadTimeOut(true);
   }
   public static void run(Runnable runnable){
      threadPoolExecutor.execute(runnable);
   }
}