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

购物网站需求分析报告网络设置

购物网站需求分析报告,网络设置,手机网站建设 上海,蜜雪加盟一般多少钱线程池的几个重要的参数#xff1a; 1、corePoolSize#xff1a;线程池的核心线程数#xff08;也是默认线程数#xff09; 2、maximumPoolSize#xff1a;最大线程数 3、keepAliveTime#xff1a;允许的线程最大空闲时间#xff08;单位/秒#xff09; 线程池内部是…线程池的几个重要的参数 1、corePoolSize线程池的核心线程数也是默认线程数 2、maximumPoolSize最大线程数 3、keepAliveTime允许的线程最大空闲时间单位/秒 线程池内部是通过队列线程实现的当我们利用线程池执行任务时 如果此时线程池中的线程数量小于corePoolSize即使线程池中的线程都处于空闲状态也要创建新的线程来处理被添加的任务 如里此时线程池中的线程数量等于corePoolSize但是缓冲队列workQueue未满那么任务被放入缓冲队列。 如果此时线程池中的线程数量大于等于corePoolSize缓中队列workQueue满并且线程池中的数量小于maximumPooISize建新的线程来外理被添加的任务。 如果此时线程池中的线程数量大于corePoosize缓冲队列workQueue满并目线程池中的数量等于maximumPoosize那么通过 handler所指定的策略来处理此任务。 当线程池中的线程数量大于 corePoolsize时如果某线程空闲时间超过keepAliveTime线程将被终止。这样线程可以动态的调整池中的线程数。 线程池的拒绝策略指的是RejectedExecutionHandler接口的实现类。 在线程池接口的源代码中可以发现ThreadPoolExecutor接口内置了4种拒绝策略。 package java.util.concurrent;public class ThreadPoolExecutor extends AbstractExecutorService {/*** A handler for rejected tasks that runs the rejected task* directly in the calling thread of the {code execute} method,* unless the executor has been shut down, in which case the task* is discarded.*/public static class CallerRunsPolicy implements RejectedExecutionHandler {/*** Creates a {code CallerRunsPolicy}.*/public CallerRunsPolicy() { }/*** Executes task r in the callers thread, unless the executor* has been shut down, in which case the task is discarded.** param r the runnable task requested to be executed* param e the executor attempting to execute this task*/public void rejectedExecution(Runnable r, ThreadPoolExecutor e) {if (!e.isShutdown()) {r.run();}}}/*** A handler for rejected tasks that throws a* {code RejectedExecutionException}.*/public static class AbortPolicy implements RejectedExecutionHandler {/*** Creates an {code AbortPolicy}.*/public AbortPolicy() { }/*** Always throws RejectedExecutionException.** param r the runnable task requested to be executed* param e the executor attempting to execute this task* throws RejectedExecutionException always*/public void rejectedExecution(Runnable r, ThreadPoolExecutor e) {throw new RejectedExecutionException(Task r.toString() rejected from e.toString());}}/*** A handler for rejected tasks that silently discards the* rejected task.*/public static class DiscardPolicy implements RejectedExecutionHandler {/*** Creates a {code DiscardPolicy}.*/public DiscardPolicy() { }/*** Does nothing, which has the effect of discarding task r.** param r the runnable task requested to be executed* param e the executor attempting to execute this task*/public void rejectedExecution(Runnable r, ThreadPoolExecutor e) {}}/*** A handler for rejected tasks that discards the oldest unhandled* request and then retries {code execute}, unless the executor* is shut down, in which case the task is discarded.*/public static class DiscardOldestPolicy implements RejectedExecutionHandler {/*** Creates a {code DiscardOldestPolicy} for the given executor.*/public DiscardOldestPolicy() { }/*** Obtains and ignores the next task that the executor* would otherwise execute, if one is immediately available,* and then retries execution of task r, unless the executor* is shut down, in which case task r is instead discarded.** param r the runnable task requested to be executed* param e the executor attempting to execute this task*/public void rejectedExecution(Runnable r, ThreadPoolExecutor e) {if (!e.isShutdown()) {e.getQueue().poll();e.execute(r);}}}} 四种拒绝策略的相关说明 1、AbortPolicy 默认。拒绝这个任务并且抛出RejectedExecutionException异常。 2、DiscardPolicy 队列满了丢掉任务不会抛出异常 3、DiscardOldestPolicy 队列满了尝试去和最早的竞争也不会抛出异常 抛弃最老任务策略也就是说如果队列满了就会将最早进入队列的任务抛弃从队列中腾出空间再尝试加入队列。因为队列是队尾进、队头出队头元素是最老的所以每次都是移除队头元素后再尝试入队。 4、CallerRunsPolicy 调用者执行策略。在新任务被添加到线程池时如果添加失败那么提交任务的线程会自己去执行该任务不会使用线程池中的线程去执行新任务。
http://www.zqtcl.cn/news/846491/

相关文章:

  • 学校网站源码小游戏网站审核怎么做
  • 西乡网站建设政务网站开发协议
  • 美食网站开发环境北京app网站建设
  • 郑州网站建设推广渠道重庆网站建设公司下载
  • 宜宾营销型网站建设网站建设需要什么资质
  • 重庆建网站有哪些学跨境电商要多少钱
  • 上海建设钢结构工程网站深圳电器公司排名
  • 淄博网站建设找淄深网江苏省建设斤网站
  • 免费行情软件app网站红色西安做网站印象网络
  • 宁波网站建设小程序开发聊城wap网站建设
  • 陇南网站网站建设泰安网站的建设
  • 哪个网站有介绍拿到家做的手工活建设银行网站怎么修改手机号码吗
  • 网站地图怎么用淘宝客推广网站建设
  • 外贸零售网站建设购物网站支付功能怎么做
  • 淘宝客如何做自己的网站西宁工程建设招聘信息网站
  • 天津都有哪些制作网站郑州官网首页
  • 个人网站开发模式海南省建设公司官网
  • edu网站开发做爰视频在线观看免费网站
  • 安防公司网站模板网站建设模板下载
  • 贵阳网站建设方案维护一 建设茶叶网站前的市场分析
  • 山东东营建设网官方网站百度电脑版
  • 做网站前途如何海尔网站建设推广
  • 投资公司网站建设万网域名安装wordpress
  • 高端网站建设企业官网建设wordpress相似推荐
  • php网站开发师招聘wordpress怎么换头像
  • 门禁考勤网站建设广西建设
  • 互助盘网站怎么做的织梦免费企业网站
  • 做羊毛毡的网站电子商务网站建设品牌
  • 用vue做商城网站常用的js教做发型的网站
  • 江西省寻乌县建设局网站广州网站建设一般多少钱