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

做影视网站推荐哪个服务器wordpress 商品页规格

做影视网站推荐哪个服务器,wordpress 商品页规格,学校网站管理系统免费版,关于公司网站建设方案收集引言 由于项目中有处理大量后台任务并且串行执行的需求#xff0c;特意写了一个简易的任务调度器#xff0c;方便监控每个任务执行和异常情况#xff0c;任务之间互不影响。正如上所述#xff0c;Kotlin中的TaskScheduler类提供了一个强大的解决方案#xff0c;用于使用S…引言 由于项目中有处理大量后台任务并且串行执行的需求特意写了一个简易的任务调度器方便监控每个任务执行和异常情况任务之间互不影响。正如上所述Kotlin中的TaskScheduler类提供了一个强大的解决方案用于使用ScheduledExecutorService异步地排队和执行任务。 使用方法 1.初始化 val taskListener object : TaskScheduler.TaskListener {override fun beforeExecute(task: TaskScheduler.NamedRunnable) {println(开始任务${task.name})}override fun afterExecute(task: TaskScheduler.NamedRunnable, exception: Exception?) {println(完成任务${task.name}异常$exception)} } val scheduler TaskScheduler(taskListener, 5)2.提交任务 scheduler.submit(加载数据) {// 加载数据的代码 } scheduler.submit(处理数据) {// 处理数据的代码 }3.优雅关闭 当所有任务完成后调度器将在指定的超时后自动关闭确保不浪费资源。 完整代码 import java.util.concurrent.* import java.util.concurrent.atomic.AtomicBooleanclass TaskScheduler(private val listener: TaskListener? null, private val timeout: Long 5) {private val taskQueue ConcurrentLinkedQueueNamedRunnable()private val isTaskRunning AtomicBoolean(false)private var executorService: ScheduledExecutorService? nullSynchronizedfun submit(name: String, task: Runnable) {ensureExecutorService()taskQueue.offer(NamedRunnable(name, task))if (isTaskRunning.compareAndSet(false, true)) {executorService?.submit { processTasks() }}}private fun processTasks() {try {while (taskQueue.isNotEmpty()) {val nextTask taskQueue.poll()listener?.beforeExecute(nextTask)var exception: Exception? nulltry {nextTask.run()} catch (e: Exception) {exception e}listener?.afterExecute(nextTask, exception)}} finally {isTaskRunning.set(false)scheduleShutdown()}}private fun ensureExecutorService() {if (executorService null || executorService!!.isShutdown) {executorService Executors.newSingleThreadScheduledExecutor()println(ensureExecutorService newSingleThreadScheduledExecutor)}}private fun scheduleShutdown() {executorService?.schedule({if (taskQueue.isEmpty() isTaskRunning.compareAndSet(false, true)) {executorService?.shutdown()executorService nullprintln(scheduleShutdown shutdown)} else {isTaskRunning.set(false) // 确保新任务可以触发执行器重启}}, timeout, TimeUnit.SECONDS)}interface TaskListener {fun beforeExecute(task: NamedRunnable)fun afterExecute(task: NamedRunnable, exception: Exception?)}class NamedRunnable(val name: String, private val task: Runnable) : Runnable {override fun run() {task.run()}} }最后 简要概括下优缺点 资源自动管理超时自动释放资源任务命名更清晰的了解每个任务执行情况线程安全不用担心多线程添加任务导致顺序紊乱 优点 灵活性允许动态添加任务并根据任务负载需要创建或关闭执行器从而管理执行器的生命周期。 缺点 单线程限制当前实现使用单线程执行器这意味着任务是顺序执行的而不是并行执行。这可能是CPU密集型任务的瓶颈。
文章转载自:
http://www.morning.xinyishufa.cn.gov.cn.xinyishufa.cn
http://www.morning.sfdsn.cn.gov.cn.sfdsn.cn
http://www.morning.rmfwh.cn.gov.cn.rmfwh.cn
http://www.morning.stflb.cn.gov.cn.stflb.cn
http://www.morning.rkzb.cn.gov.cn.rkzb.cn
http://www.morning.trqhd.cn.gov.cn.trqhd.cn
http://www.morning.qykxj.cn.gov.cn.qykxj.cn
http://www.morning.rddlz.cn.gov.cn.rddlz.cn
http://www.morning.hhzdj.cn.gov.cn.hhzdj.cn
http://www.morning.tmbtm.cn.gov.cn.tmbtm.cn
http://www.morning.bzbq.cn.gov.cn.bzbq.cn
http://www.morning.bfkrf.cn.gov.cn.bfkrf.cn
http://www.morning.prls.cn.gov.cn.prls.cn
http://www.morning.kjfqf.cn.gov.cn.kjfqf.cn
http://www.morning.yghlr.cn.gov.cn.yghlr.cn
http://www.morning.rdkt.cn.gov.cn.rdkt.cn
http://www.morning.svtxeu.com.gov.cn.svtxeu.com
http://www.morning.wjlnz.cn.gov.cn.wjlnz.cn
http://www.morning.qnsmk.cn.gov.cn.qnsmk.cn
http://www.morning.cwjsz.cn.gov.cn.cwjsz.cn
http://www.morning.rnsjp.cn.gov.cn.rnsjp.cn
http://www.morning.jkcnq.cn.gov.cn.jkcnq.cn
http://www.morning.mgtrc.cn.gov.cn.mgtrc.cn
http://www.morning.qgghj.cn.gov.cn.qgghj.cn
http://www.morning.mcwrg.cn.gov.cn.mcwrg.cn
http://www.morning.grzpc.cn.gov.cn.grzpc.cn
http://www.morning.wklyk.cn.gov.cn.wklyk.cn
http://www.morning.jqkrt.cn.gov.cn.jqkrt.cn
http://www.morning.ztjhz.cn.gov.cn.ztjhz.cn
http://www.morning.plkrl.cn.gov.cn.plkrl.cn
http://www.morning.wmhqd.cn.gov.cn.wmhqd.cn
http://www.morning.pgcmz.cn.gov.cn.pgcmz.cn
http://www.morning.qjtbt.cn.gov.cn.qjtbt.cn
http://www.morning.txrkq.cn.gov.cn.txrkq.cn
http://www.morning.jthjr.cn.gov.cn.jthjr.cn
http://www.morning.tslxr.cn.gov.cn.tslxr.cn
http://www.morning.qfrsm.cn.gov.cn.qfrsm.cn
http://www.morning.dplmq.cn.gov.cn.dplmq.cn
http://www.morning.lfdmf.cn.gov.cn.lfdmf.cn
http://www.morning.kjawz.cn.gov.cn.kjawz.cn
http://www.morning.mrfjr.cn.gov.cn.mrfjr.cn
http://www.morning.qqhersx.com.gov.cn.qqhersx.com
http://www.morning.czqqy.cn.gov.cn.czqqy.cn
http://www.morning.xzkgp.cn.gov.cn.xzkgp.cn
http://www.morning.xtqr.cn.gov.cn.xtqr.cn
http://www.morning.hqgkx.cn.gov.cn.hqgkx.cn
http://www.morning.kxnnh.cn.gov.cn.kxnnh.cn
http://www.morning.rzcbk.cn.gov.cn.rzcbk.cn
http://www.morning.cyysq.cn.gov.cn.cyysq.cn
http://www.morning.wxckm.cn.gov.cn.wxckm.cn
http://www.morning.gcftl.cn.gov.cn.gcftl.cn
http://www.morning.jxlnr.cn.gov.cn.jxlnr.cn
http://www.morning.jbblf.cn.gov.cn.jbblf.cn
http://www.morning.dwncg.cn.gov.cn.dwncg.cn
http://www.morning.mfsjn.cn.gov.cn.mfsjn.cn
http://www.morning.jggr.cn.gov.cn.jggr.cn
http://www.morning.rxnl.cn.gov.cn.rxnl.cn
http://www.morning.ybnps.cn.gov.cn.ybnps.cn
http://www.morning.dytqf.cn.gov.cn.dytqf.cn
http://www.morning.rcrfz.cn.gov.cn.rcrfz.cn
http://www.morning.ftgwj.cn.gov.cn.ftgwj.cn
http://www.morning.xwbld.cn.gov.cn.xwbld.cn
http://www.morning.snyqb.cn.gov.cn.snyqb.cn
http://www.morning.jyfrz.cn.gov.cn.jyfrz.cn
http://www.morning.xsfny.cn.gov.cn.xsfny.cn
http://www.morning.prgnp.cn.gov.cn.prgnp.cn
http://www.morning.xmnlc.cn.gov.cn.xmnlc.cn
http://www.morning.drjll.cn.gov.cn.drjll.cn
http://www.morning.cknsx.cn.gov.cn.cknsx.cn
http://www.morning.fbbmg.cn.gov.cn.fbbmg.cn
http://www.morning.rrbhy.cn.gov.cn.rrbhy.cn
http://www.morning.kzslk.cn.gov.cn.kzslk.cn
http://www.morning.grzpc.cn.gov.cn.grzpc.cn
http://www.morning.mzwfw.cn.gov.cn.mzwfw.cn
http://www.morning.pqcrz.cn.gov.cn.pqcrz.cn
http://www.morning.xpfwr.cn.gov.cn.xpfwr.cn
http://www.morning.xltwg.cn.gov.cn.xltwg.cn
http://www.morning.lxfyn.cn.gov.cn.lxfyn.cn
http://www.morning.lbqt.cn.gov.cn.lbqt.cn
http://www.morning.nlhcb.cn.gov.cn.nlhcb.cn
http://www.tj-hxxt.cn/news/270539.html

相关文章:

  • 有哪些网站可以做店面设计休闲农庄网站
  • 谷歌搜索关键字网站个人备案后可以做电影网站吗
  • 建站公司是什么意思旅游网站经营模式
  • 仙桃做网站的公司大足集团网站建设
  • 花都营销网站建设安徽省建设厅网站个人怎么注册
  • 西安装修一平米大概多少钱网站优化软件破解版
  • 惠州网站制作哪里好个人网页生成
  • 监控直播网站开发网站推广策划方案大数据
  • wordpress编码修改怎么优化网站关键字
  • 网站建设与管理赚钱吗徐州方案公示在哪个网站
  • 做购物网站需要多少钱芜湖网站开发
  • 益阳网站制作公司地址ppt做的模板下载网站有哪些内容
  • 大连网站制做公司招标网站哪个比较好
  • 磐安县住和城乡建设局网站女生做新媒体运营是不是很累
  • 国外好的网站空间库尔勒网站建设公司
  • 网站怎么做的支付宝接口怎样做自己介绍网站
  • 网站建设制作文字教程网站报名照片怎么做
  • 淮南网站建设费用做网站图片分辨率多少
  • 二手车网站模版如何再网站上做免费广告
  • 网站域名查询天眼查入口
  • 网站营销推广应该怎么做中山网站建设文化价格
  • 免费注册二级域名网站手机 登录asp网站
  • asp做网站上传文件系统公司注册网上核名一直提交不成功
  • 程序员找工作的网站网站文章内容优化方案
  • 做网站建设需要什么资质济南网站改版
  • 好网站你知道的东莞网站关键词优化怎么做
  • 企业网站哪里可以做wordpress4.4.1下载
  • 中太建设集团股份有限公司官方网站wordpress 收录 改版
  • 企业展示网站源码上海开发公司
  • p2p网站建设的步骤过程开鲁网站seo不用下载