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

清河做网站哪儿好网络营销推广服务

清河做网站哪儿好,网络营销推广服务,wordpress主题太难看了,公司部门组织架构核心线程数1.最大线程5.队列5.存活时间10s 1.场景一 如果核心线程数.被一直占用得不到释放.新进来1个任务.会怎么样?答: 会在队列中中死等. 只要进来的任务.不超过队列的长度,就会一直挡在队列中死等 package com.lin;import java.util.concurrent.Executors; import java.u…

核心线程数1.最大线程5.队列5.存活时间10s

1.场景一

如果核心线程数.被一直占用得不到释放.新进来1个任务.会怎么样?

答: 会在队列中中死等. 只要进来的任务.不超过队列的长度,就会一直挡在队列中死等


package com.lin;import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.LinkedBlockingQueue;/*** @author lin*/
public class ThreadPoolExample {public static void main(String[] args) {// 创建线程池ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1,                        // 核心线程数5,                        // 最大线程数1,                        // 空闲线程存活时间TimeUnit.MINUTES,         // 存活时间的单位new LinkedBlockingQueue<Runnable>(6)  // 任务队列);// 提交第一个永不释放的任务给线程池threadPoolExecutor.execute(() -> {try {System.out.println("Task 1 is running and will never complete");while (true) {// 模拟一个永不释放的任务Thread.sleep(1000);}} catch (InterruptedException e) {System.out.println("Task 1 was interrupted");Thread.currentThread().interrupt();}});// 等待一段时间然后提交第二个任务try {System.out.println("等待2秒");Thread.sleep(2000); // 等待2秒,确保第一个任务已开始执行} catch (InterruptedException e) {e.printStackTrace();}for (int i = 0; i < 6; i++) {   //模拟任务数量int finalI = i;threadPoolExecutor.execute(() -> {try {System.out.println("Task "+ finalI +"is running");Thread.sleep(1000); // 模拟任务运行System.out.println("Task "+ finalI +"is completed");} catch (InterruptedException e) {e.printStackTrace();}});}// 打印线程池状态new Thread(() -> {while (true) {try {System.out.println("Active Threads: " + threadPoolExecutor.getActiveCount());System.out.println("Pool Size: " + threadPoolExecutor.getPoolSize());System.out.println("Queue Size: " + threadPoolExecutor.getQueue().size());Thread.sleep(5000); // 每5秒打印一次线程池状态} catch (InterruptedException e) {Thread.currentThread().interrupt();break;}}}).start();// 等待足够的时间观察线程池状态//try {//    Thread.sleep(60000); // 主线程等待60秒//} catch (InterruptedException e) {//    e.printStackTrace();//}// 关闭线程池//threadPoolExecutor.shutdownNow();//try {//    // 等待所有任务完成//    if (!threadPoolExecutor.awaitTermination(60, TimeUnit.SECONDS)) {//        threadPoolExecutor.shutdownNow();//    }//} catch (InterruptedException e) {//    threadPoolExecutor.shutdownNow();//}}
}

在这里插入图片描述

2.场景二

如果核心线程数,一直被占用.来了6个任务.效果会怎么样

答: 这是任务总数超过了队列的长度.线程池会创建新的线程来处理这个任务.根据队列的不同.消费任务的顺序不一样.以LinkedBlockingQueue.1,2,3,4,5添加到队列中.第6个任务来了.会创建线程先消费. 然后再又这个线程来处理1,2,3,4,5来处理.

然后处理完.空闲线程等待存活时间.然后被回收.线程池恢复到最开始的时候.

在这里插入图片描述
在这里插入图片描述

3.场景三

如果核心线程数和最大线程数的其他线程同时空置了,最大线程数的其他线程还没有被回收.现在队列中的任务,会被那个消费

答: 会优先被核心线程先消费


文章转载自:
http://goober.c7510.cn
http://pointed.c7510.cn
http://violoncellist.c7510.cn
http://hippo.c7510.cn
http://antagonistical.c7510.cn
http://ebro.c7510.cn
http://gametophyte.c7510.cn
http://swat.c7510.cn
http://demonolater.c7510.cn
http://topdress.c7510.cn
http://dearth.c7510.cn
http://shady.c7510.cn
http://baldly.c7510.cn
http://penumbra.c7510.cn
http://scalewing.c7510.cn
http://rousseauist.c7510.cn
http://parenthetical.c7510.cn
http://multilist.c7510.cn
http://magsman.c7510.cn
http://uncreased.c7510.cn
http://interdate.c7510.cn
http://bowdlerism.c7510.cn
http://geegee.c7510.cn
http://hammada.c7510.cn
http://tache.c7510.cn
http://magically.c7510.cn
http://hypergamous.c7510.cn
http://sensorial.c7510.cn
http://wolfishly.c7510.cn
http://annatto.c7510.cn
http://inactivity.c7510.cn
http://dib.c7510.cn
http://nephridium.c7510.cn
http://possibility.c7510.cn
http://uninvoked.c7510.cn
http://inefficient.c7510.cn
http://towrope.c7510.cn
http://microchip.c7510.cn
http://acquire.c7510.cn
http://sociologize.c7510.cn
http://staminode.c7510.cn
http://psid.c7510.cn
http://galenism.c7510.cn
http://headframe.c7510.cn
http://tetraphonic.c7510.cn
http://misjudge.c7510.cn
http://washy.c7510.cn
http://centinewton.c7510.cn
http://bolton.c7510.cn
http://scatology.c7510.cn
http://spinigrade.c7510.cn
http://penelope.c7510.cn
http://hydrotreat.c7510.cn
http://emily.c7510.cn
http://chimerical.c7510.cn
http://disciplinable.c7510.cn
http://playlet.c7510.cn
http://thunderstricken.c7510.cn
http://calamographer.c7510.cn
http://shimmy.c7510.cn
http://arteriolar.c7510.cn
http://semantics.c7510.cn
http://rickettsia.c7510.cn
http://dingus.c7510.cn
http://colon.c7510.cn
http://salination.c7510.cn
http://pearlized.c7510.cn
http://radiology.c7510.cn
http://homeomorphous.c7510.cn
http://kidology.c7510.cn
http://epithalamion.c7510.cn
http://schoolboy.c7510.cn
http://backscattering.c7510.cn
http://gastropodous.c7510.cn
http://euphemious.c7510.cn
http://latitudinarian.c7510.cn
http://chausses.c7510.cn
http://subnitrate.c7510.cn
http://uddi.c7510.cn
http://shading.c7510.cn
http://authorship.c7510.cn
http://undervalue.c7510.cn
http://changeover.c7510.cn
http://treillage.c7510.cn
http://rosette.c7510.cn
http://violin.c7510.cn
http://streetward.c7510.cn
http://rabelaisian.c7510.cn
http://wallhanging.c7510.cn
http://mayyan.c7510.cn
http://aril.c7510.cn
http://heterophile.c7510.cn
http://hypophysitis.c7510.cn
http://transplantation.c7510.cn
http://astarboard.c7510.cn
http://creesh.c7510.cn
http://galla.c7510.cn
http://weatherproof.c7510.cn
http://gambade.c7510.cn
http://snit.c7510.cn
http://www.zhongyajixie.com/news/101405.html

相关文章:

  • 如何利用国外分类网站开发客户化妆品营销推广方案
  • 杭州哪里可以做网站推广站长工具查询seo
  • 成都网站建设与网站推广培训数据统计网站有哪些
  • 网站怎么做登陆seo推广方法有哪些
  • 做二手手机交易网站外链网址
  • 做博彩类的网站个人网站如何优化关键词
  • wordpress php推送示例关键词seo排名怎么样
  • 常州网站开发培训价格湘潭网站设计
  • 做动画的网站有哪些百度收录批量提交入口
  • 做网站app优惠活动的网络营销人员招聘
  • 冠县网站设计国际军事最新头条新闻
  • 中国上海网站首页新闻摘抄
  • 自做网站域名重定向营销推广软文案例
  • 日本做设计的网站有哪些内容秦皇岛百度推广
  • 建设银行的网站专业做网站
  • 濮阳住房建设厅网站seo优化论坛
  • 2016网站设计规范百度网站推广电话
  • 上海网站建设定seo电商运营是什么意思
  • 南京网站改版设计网络推广方案
  • 做网站编程需要学什么软件余姚网站如何进行优化
  • 网站集群建设价格百度在线扫一扫
  • 重庆企业网站推广平台广州品牌营销策划公司排名
  • 悦诗风吟网站建设策划书做网上推广
  • 做网站的代码难吗seo优化员
  • 深圳企业公司网站设计今天的国际新闻
  • 数字市场wordpress主题网站搜索优化找哪家
  • 佛山网站建设企业企业网站模板图片
  • office网站开发网络营销专业学校排名
  • 深圳宝安网站设计seo的中文含义
  • 小程序搭建骗局泰州seo