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

网站百度地图标记代码哪里可以检测丙型肝炎

网站百度地图标记代码,哪里可以检测丙型肝炎,婚纱网站布局ppt怎么做,wordpress rds提交时是使用防抖还是节流JDK的java.util.concurrent.ThreadPoolExecutor允许您将任务提交到线程池#xff0c;并使用BlockingQueue来保存提交的任务。 如果要提交的任务有数千个#xff0c;请指定一个“绑定”队列#xff08;即最大容量的队列#xff09;#xff0c;否则… 提交时是使用防抖还是节流 JDK的java.util.concurrent.ThreadPoolExecutor允许您将任务提交到线程池并使用BlockingQueue来保存提交的任务。 如果要提交的任务有数千个请指定一个“绑定”队列即最大容量的队列否则JVM可能会用完内存。 您可以设置RejectedExecutionHandler来处理队列已满时发生的情况但是仍然有待提交的任务。 这里是你展示如何使用一个简单的例子ThreadPoolExecutor具有BlockingQueue容量1000 CallerRunsPolicy确保当队列已满时其他任务将由提交线程处理。 int numThreads 5; ExecutorService exec new ThreadPoolExecutor(5, 5, 0L, TimeUnit.MILLISECONDS,new ArrayBlockingQueueRunnable(1000),new ThreadPoolExecutor.CallerRunsPolicy()); 这种方法的问题在于当队列已满时向池提交任务的线程会变得忙于执行任务本身在此期间队列可能会变空并且池中的线程可能会变得空闲。 这不是很有效。 我们希望一直保持线程池繁忙并且工作队列始终处于饱和状态。 有各种解决方案。 其中之一是使用自定义的Executor 当队列已满时该Executor将阻止从而防止其他任务提交到池中。 BlockingExecutor的代码如下所示。 它基于Brian Goetz2006年的BoundedExecutor示例。Java Concurrency in Practice。 1版。 Addison-Wesley专业。 第8.3.3节 。 import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.Semaphore; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit;import org.slf4j.Logger; import org.slf4j.LoggerFactory;/*** An executor which blocks and prevents further tasks from* being submitted to the pool when the queue is full.* p* Based on the BoundedExecutor example in:* Brian Goetz, 2006. Java Concurrency in Practice. (Listing 8.4)*/ public class BlockingExecutor extends ThreadPoolExecutor {private static final Logger LOGGER LoggerFactory.getLogger(BlockingExecutor.class);private final Semaphore semaphore;/*** Creates a BlockingExecutor which will block and prevent further* submission to the pool when the specified queue size has been reached.** param poolSize the number of the threads in the pool* param queueSize the size of the queue*/public BlockingExecutor(final int poolSize, final int queueSize) {super(poolSize, poolSize, 0L, TimeUnit.MILLISECONDS,new LinkedBlockingQueueRunnable());// the semaphore is bounding both the number of tasks currently executing// and those queued upsemaphore new Semaphore(poolSize queueSize);}/*** Executes the given task.* This method will block when the semaphore has no permits* i.e. when the queue has reached its capacity.*/Overridepublic void execute(final Runnable task) {boolean acquired false;do {try {semaphore.acquire();acquired true;} catch (final InterruptedException e) {LOGGER.warn(InterruptedException whilst aquiring semaphore, e);}} while (!acquired);try {super.execute(task);} catch (final RejectedExecutionException e) {semaphore.release();throw e;}}/*** Method invoked upon completion of execution of the given Runnable,* by the thread that executed the task.* Releases a semaphore permit.*/Overrideprotected void afterExecute(final Runnable r, final Throwable t) {super.afterExecute(r, t);semaphore.release();} } 参考我们的JCG合作伙伴 Fahd Shariff在fahd.blog博客上使用BlockingExecutor进行节流任务提交 。 翻译自: https://www.javacodegeeks.com/2013/11/throttling-task-submission-with-a-blockingexecutor.html提交时是使用防抖还是节流
http://www.pierceye.com/news/585090/

相关文章:

  • 网站建设哪家性价比高住房和城乡建设部网站办事大厅里边
  • 外贸小语种网站建设深圳市保障性住房申请官网
  • 阿里云买域名后怎么做网站wordpress创建空白页面
  • 小型公司建网站腾讯风铃wordpress
  • 广州做模板网站的公司怎么区分营销型和展示型的网站
  • 网站推广服务外包1688阿里巴巴国际站首页
  • 深圳学校网站建设wordpress rossi 汉化
  • 课程网站课程资源建设北京吴勇设计工作室
  • 网站建设费用什么意思软件制作专业
  • 扬中本地网站外国做美食视频网站
  • 深圳手机网站制作价钱阜阳中国建设银行官网站
  • 廊坊建设网站企业安卓开发自学教程
  • 做网站虚拟主机配置汉沽手机网站建设
  • 设计一个网站先做哪些构造姑苏区建设局网站
  • 制造业营销外贸网站建设网站管理的内容包括
  • 看电视剧的免费网站app下载网站等保如何做
  • 如何做网站的营销中山vi设计公司
  • 搜索引擎网站使用的排名规则室内设计联盟网页版
  • php 手机网站开发手机端网站开发框架
  • 苏州电信网站备案浙江搜索引擎优化
  • 黄岛网站建设哪家好市体育局网站 两学一做
  • 上海建设银行网站转账记录吗外国网站做问卷调查挣钱
  • 深圳做购物网站十堰网络销售
  • 郑州企业网站优化多少钱百度竞价排名价格
  • js特效做的好的网站什么专业是做网站
  • 淄川响应式网站建设网站在国内服务器在国外
  • 施工企业市场经营工作思路及措施个人如何优化网站有哪些方法
  • 怎么做一个盈利网站义乌创博网络科技有限公司
  • 学校网站建设代码不重名的建筑公司名字
  • 网站开发模块的需求海外销售平台有哪些