当前位置: 首页 > news >正文

常用seo站长工具设计素材网站月收益

常用seo站长工具,设计素材网站月收益,设计机构网站,主流网站类型1#xff0c;这是线程池管理工具类#xff0c;在系统关闭时确保任务执行完毕#xff0c;自定义线程名字#xff0c;自定义抛弃策略默认使用了CallerRunsPolicy拒绝策略 import java.util.concurrent.ExecutorService; import java.util.concurrent.LinkedBlockingQueue;imp…1这是线程池管理工具类在系统关闭时确保任务执行完毕自定义线程名字自定义抛弃策略默认使用了CallerRunsPolicy拒绝策略 import java.util.concurrent.ExecutorService; import java.util.concurrent.LinkedBlockingQueue;import java.util.concurrent.ThreadFactory; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.ThreadPoolExecutor.CallerRunsPolicy; import java.util.concurrent.TimeUnit;import org.slf4j.Logger; import org.slf4j.LoggerFactory;/*** author yannan * 20231128*/public class ThreadUtil {private static final Logger logger LoggerFactory.getLogger(ThreadUtil.class);public static class CustomThreadFactory implements ThreadFactory {private final String namePrefix;public CustomThreadFactory(String namePrefix) {this.namePrefix namePrefix;}public Thread newThread(Runnable runnable) {Thread thread new Thread(runnable);thread.setName(namePrefix thread.getId());return thread;}}/*** 轮询等待ExecutorService线程池中所有线程执行完毕* * param executorService*/public static void isTerminated(ExecutorService executorService) {StringBuffer sb new StringBuffer();executorService.submit(() - {sb.append(Thread.currentThread().getName());// System.out.println(Task executed by thread: threadName);});executorService.shutdown();// 轮询等待ExecutorService线程池中所有线程执行完毕while (true) {if (executorService.isTerminated()) {// System.err.println(executorService.getClass().getName() end);logger.info(线程池 sb.toString() END 关闭成功);break;}try {Thread.sleep(10);} catch (InterruptedException e) {// TODO Auto-generated catch blocke.printStackTrace();}}}/*** 等待超时* * param executorService*/public static void awaitTermination(ExecutorService executorService) {try {executorService.awaitTermination(5 * 60, TimeUnit.SECONDS);} catch (InterruptedException e) {e.printStackTrace();logger.info(等待超时直接关闭);}}/*** */public static ExecutorService newSingleThreadExecutor(String threadName) {// Log-Thread-ThreadFactory threadFactory new ThreadUtil.CustomThreadFactory(threadName);ExecutorService executorService new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS,new LinkedBlockingQueueRunnable(), threadFactory, callerRunsPolicy());return executorService;}public static ExecutorService newFixedThreadPool(int nThreads, String threadName) {ThreadFactory threadFactory new ThreadUtil.CustomThreadFactory(threadName);ExecutorService executorService new ThreadPoolExecutor(nThreads, nThreads, 0L, TimeUnit.MILLISECONDS,new LinkedBlockingQueueRunnable(), threadFactory, callerRunsPolicy());return executorService;}/*** CallerRunsPolicy拒绝策略相对而言它就比较完善了当有新任务提交后如果线程池没被关闭且没有能力执行则把这个任务交于提交任务的线程执行也就是谁提交任务谁就负责执行任务。这样做主要有两点好处。* return*/public static CallerRunsPolicy callerRunsPolicy() {return new ThreadPoolExecutor.CallerRunsPolicy();}public static int getCorePoolSize(ExecutorService executorService) {int threadSize 0;if (executorService instanceof ThreadPoolExecutor) {threadSize ((ThreadPoolExecutor) executorService).getCorePoolSize();logger.info(核心线程数量为 threadSize);}return threadSize;} }
http://wiki.neutronadmin.com/news/225435/

相关文章:

  • 自适应网站好还是网页文字游戏
  • 成都网站设计公司wordpress第三方订阅地址
  • 网站空间续费多钱一年wordpress 的导航插件
  • 怎么弄网站做网站卖东西广告牌设计效果图
  • 做网站能用微软semester
  • 做网页网站 的公司wordpress 多语言 主题
  • php 开源的企业网站镇江微淘软件开发
  • html5微网站模板辽宁省建设厅官方网
  • 实现网站计划书代理平台推荐
  • 广州h5网站建设公司贵阳网站建设 设计可以吗
  • 网站公司的利润在哪里软装设计网站排名
  • 做问卷调查的网站有哪些网站导航的作用
  • 做网站的意义大不大网站开发专业能力
  • 导航网站怎么建电子商务的概念和特点是什么
  • 台州椒江做网站客户信息管理
  • 建设部网站撤销注册资质的都是公职人员吗北京的网站开发公司
  • 网站建设指导合同北海哪里做网站
  • 网站建设金wordpress留言板comments.php添加自定义字段
  • 网站开发设计过程西安建筑类公司
  • 网站备案号 怎么写会员营销
  • 公司网站建设工作ss网站模板免费下载
  • 网站留言板html代码网页制作教程教案
  • 鞍山 中企动力提供网站建设学校网站建设开发商
  • 华安县城乡规划建设局网站给单位建设网站
  • 网站建设 付款方式制作公司网站视频
  • 比较好的网站建设哪家好优科技网站建设
  • .net 开发门户网站顾问
  • 网站管理难做吗长沙网站搜索排名
  • 重庆网站开发解决方案网络规划工程师
  • 池州专业网站建设上海网站备案公司