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

建设个人网站的参考网站及文献西安最新消息

建设个人网站的参考网站及文献,西安最新消息,网站htm建设,短视频特效制作软件CountDownLatch 翻译#xff1a; 倒计时锁存器#xff0c;#xff0c;#xff0c;#xff0c;count计数#xff0c;down停止#xff0c;Latch锁 解释#xff1a; 允许一个或多个线程等待#xff0c;直到在其他线程中执行的一组操作完成的同步辅助不懂#xff1f;…CountDownLatch 翻译 倒计时锁存器count计数down停止Latch锁 解释 允许一个或多个线程等待直到在其他线程中执行的一组操作完成的同步辅助不懂就是正常情况下多线程是同时处于就绪状态但是使用了之后我【线程一】先跑你们在外面候着 方法 使用 简单使用 public static void main(String[] args) throws InterruptedException {CountDownLatch countDownLatch new CountDownLatch(10);for (int i 0; i 10; i) {int finalI i;new Thread(()-{System.out.println(finalI);countDownLatch.countDown();}).start();}countDownLatch.await();System.out.println(结束了); }在线程里使用每次减少 1await后面的进程需要等到上面的进程执行完毕才可以执行 问题 如何使用CountDownLatch使得角色裁判喊完各就位预备后发枪这个两个动作后运动员才开始跑 需要使用callable接口而不是runnable接口 复杂使用 裁判类 【Judge】 class Judge implements CallableString{private CountDownLatch startCreamLatch;private CountDownLatch startFireLatch;public Judge(CountDownLatch startCreamLatch, CountDownLatch startFireLatch) {this.startCreamLatch startCreamLatch;this.startFireLatch startFireLatch;}Overridepublic String call() throws Exception {scream();this.startCreamLatch.countDown();this.startCreamLatch.await();fire();this.startFireLatch.countDown();this.startFireLatch.await();return 裁判发枪成功;}public void scream (){System.out.println(裁判喊各就位);}public void fire(){System.out.println(开枪);} }定义了scream的CountDownLatch 和 fire的 CountDownLatch在主类中分别设置倒计时为1每次执行完即可以执行下一个 运动员类【runner】 class Runner implements CallableString{private CountDownLatch startLatch;public Runner(CountDownLatch startLatch) {this.startLatch startLatch;}Overridepublic String call() throws Exception {this.startLatch.await();run();return Thread.currentThread().getName() 运动员正在运动;}public void run(){System.out.println(Thread.currentThread().getName()运动员跑起来了);} }主线程【main】 public class Game{public static void main(String[] args) {CountDownLatch startCreamLatch new CountDownLatch(1);CountDownLatch startFireLatch new CountDownLatch(1);Judge judge new Judge(startCreamLatch,startFireLatch);Runner runner new Runner(startFireLatch);FutureTask futureTask new FutureTask(judge);new Thread(futureTask).start();for (int i 0; i 8; i) {FutureTask task new FutureTask(runner);new Thread(task,第String.valueOf(i)运动员).start();}} }
http://www.w-s-a.com/news/953840/

相关文章:

  • 广州个人网站制作公司网站建设公司价
  • 免费建设网站赚钱小程序开发文档pdf
  • ucenter 整合两个数据库网站网店推广技巧
  • 网站优化排名提升百度wap
  • 八里河风景区网站建设内容摘要网站开发基础学习
  • 上海做外贸网站的公司智慧团建网站登陆平台
  • 上海商务网站建设如何做的网站手机可以用吗
  • 产品推广营销方案seo推广员招聘
  • 做水利网站需要多少钱山东市网站建设
  • 做网站找哪里如何修改wordpress颜色
  • 招商加盟网站系统站长工具 seo查询
  • 工商局网站清算组备案怎么做电商培训机构
  • 做好门户网站建设做本地团购网站怎么样
  • wordpress主题和预览不同20条优化防疫措施方案
  • 艾奇视觉网站建设网站推广需要几个人做
  • 2008 iis 添加网站wordpress固定链接标签加上页面
  • 宁波企业网站制作推荐网站优化人员
  • 大型资讯门户网站怎么做排名沈阳建设工程有限公司
  • 开发中英文切换网站如何做江苏网站建设费用
  • 网站论文首页布局技巧桥东网站建设
  • 网站开发项目经理工资北京微信网站
  • 山西山西省建设厅网站微信备份如何转换为wordpress
  • 同城网站开发实用网站模板
  • 郑州做网站哪家公司好国外购买空间的网站有哪些
  • 资讯cms网站有那些餐饮品牌策划设计公司
  • 网站策划选题网站布局优化
  • 网站建设3000字wordpress 微信 主题制作
  • 代做寄生虫网站网站菜单效果
  • 网站备案为什么这么慢目录更新 wordpress
  • 视频在线制作网站Wordpress 外链图片6