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

沈阳专业网站制作团队自己怎么做网站啊

沈阳专业网站制作团队,自己怎么做网站啊,logopond设计网站,wordpress做登录界面本文介绍两种主线程等待子线程的实现方式#xff0c;以5个子线程来说明#xff1a;1、使用Thread的join()方法#xff0c;join()方法会阻塞主线程继续向下执行。2、使用Java.util.concurrent中的CountDownLatch#xff0c;是一个倒数计数器。初始化时先设置一个倒数计数初始…本文介绍两种主线程等待子线程的实现方式以5个子线程来说明1、使用Thread的join()方法join()方法会阻塞主线程继续向下执行。2、使用Java.util.concurrent中的CountDownLatch是一个倒数计数器。初始化时先设置一个倒数计数初始值每调用一次countDown()方法倒数值减一他的await()方法会阻塞当前进程直到倒数至0。join方式代码如下package com.test.thread;import java.util.ArrayList;import java.util.List;public class MyThread extends Thread{public MyThread(String name){this.setName(name);}Overridepublic void run(){System.out.println(this.getName() staring...);System.out.println(this.getName() end...);}/*** param args*/public static void main(String[] args){System.out.println(main thread starting...);List list new ArrayList();for (int i 1; i 5; i){MyThread my new MyThread(Thrad i);my.start();list.add(my);}try{for (MyThread my : list){my.join();}}catch (InterruptedException e){e.printStackTrace();}System.out.println(main thread end...);}}运行结果如下main thread starting...Thrad 2 staring...Thrad 2 end...Thrad 4 staring...Thrad 4 end...Thrad 1 staring...Thrad 1 end...Thrad 3 staring...Thrad 3 end...Thrad 5 staring...Thrad 5 end...main thread end...CountDownLatch方式代码如下package com.test.thread;import java.util.concurrent.CountDownLatch;public class MyThread2 extends Thread{private CountDownLatch count;public MyThread2(CountDownLatch count, String name){this.count count;this.setName(name);}Overridepublic void run(){System.out.println(this.getName() staring...);System.out.println(this.getName() end...);this.count.countDown();}/*** param args*/public static void main(String[] args){System.out.println(main thread starting...);CountDownLatch count new CountDownLatch(5);for (int i 1; i 5; i){MyThread2 my new MyThread2(count, Thread i);my.start();}try{count.await();}catch (InterruptedException e){e.printStackTrace();}System.out.println(main thread end...);}}运行结果如下main thread starting...Thread 2 staring...Thread 2 end...Thread 4 staring...Thread 4 end...Thread 1 staring...Thread 1 end...Thread 3 staring...Thread 3 end...Thread 5 staring...Thread 5 end...main thread end..转自http://blog.csdn.net/nms312/article/details/30115055
http://www.zqtcl.cn/news/276659/

相关文章:

  • 海口网站seo做网站域名后缀选择
  • 网站建设新手看什么书网络营销推广师
  • 小浣熊做单网站观看床做视频网站
  • 网站版面布局结构图门户网站要求
  • 网站左侧广告代码网站建设交接协议书
  • dedecms网站上传华为网络营销案例分析
  • wordpress搭建站点龙岗网站建设代理商
  • 做销售网站要多少钱建立网站的流程
  • 视频类网站如何做缓存网页设计框架怎么写
  • wordpress建站访问提示不安全网页加速器哪个最好用
  • 网博士自助建站系统下载毕业设计代做网站唯一
  • 江西网站建设优化服务营销软文范例大全100字
  • 图片类网站怎样做高并发专业做旗袍花的网站是什么网站
  • 我要建网站需要什么专业网站制作全包
  • 网站开发合同印花税自定义手机网站建设
  • 营销型网站开发流程制作网站需要钱吗
  • 提供有经验的网站建设百度识图识别
  • html手机网站怎么做湖南关键词优化品牌推荐
  • 网站定制开发收费标准是多少易语言如何做浏网站
  • 网站怎么做实名认证新手怎么开婚庆公司
  • .net做网站用什么技术网站优化排名方案
  • 电商网站备案流程网站移动端优化的重点有哪些
  • 数据需求 网站建设做qq空间的网站
  • 微信网站游戏网络规划设计师可以挂证吗
  • 有个做特价的购物网站网站建设与维护题库及答案
  • 长沙网站优化价格创意设计师个人网站
  • 滨河网站建设南京免费发布信息网站
  • 蓝色系列的网站邓砚谷电子商务网站建设
  • 德阳市住房和城乡建设局网站首页一个服务器可以建多少个网站
  • 建一个电商网站多少钱一起做网店货源app