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

静态网站怎么做有效页上海建设安全协会网站

静态网站怎么做有效页,上海建设安全协会网站,品牌广告投放,网站链群怎么做一个线程如何知道另一线程已经结束#xff1f;Thread类提供了回答此问题的方法。有两种方法可以判定一个线程是否结束。第一#xff0c;可以在线程中调用isAlive()。这种方法由Thread定义#xff0c;它的通常形式如下#xff1a;final boolean isAlive( )如果所调用线程仍在…一个线程如何知道另一线程已经结束Thread类提供了回答此问题的方法。有两种方法可以判定一个线程是否结束。第一可以在线程中调用isAlive()。这种方法由Thread定义它的通常形式如下final boolean isAlive( )如果所调用线程仍在运行isAlive()方法返回true如果不是则返回false。但isAlive()很少用到等待线程结束的更常用的方法是调用join()描述如下final void join( ) throws InterruptedException该方法等待所调用线程结束。该名字来自于要求线程等待直到指定线程参与的概念。join()的附加形式允许给等待指定线程结束定义一个最大时间。下面是前面例子的改进版本。运用join()以确保主线程最后结束。同样它也演示了isAlive()方法。// Using join() to wait for threads to finish.class NewThread implements Runnable {String name; // name of threadThread t;NewThread(String threadname) {name threadname;t new Thread(this, name);System.out.println(New thread: t);t.start(); // Start the thread}// This is the entry point for thread.public void run() {try {for(int i 5; i 0; i--) {System.out.println(name : i);Thread.sleep(1000);}} catch (InterruptedException e) {System.out.println(name interrupted.);}System.out.println(name exiting.);}}class DemoJoin {public static void main(String args[]) {NewThread ob1 new NewThread(One);NewThread ob2 new NewThread(Two);NewThread ob3 new NewThread(Three);System.out.println(Thread One is alive: ob1.t.isAlive());System.out.println(Thread Two is alive: ob2.t.isAlive());System.out.println(Thread Three is alive: ob3.t.isAlive());// wait for threads to finishtry {System.out.println(Waiting for threads to finish.);ob1.t.join();ob2.t.join();ob3.t.join();} catch (InterruptedException e) {System.out.println(Main thread Interrupted);}System.out.println(Thread One is alive: ob1.t.isAlive());System.out.println(Thread Two is alive: ob2.t.isAlive());System.out.println(Thread Three is alive: ob3.t.isAlive());System.out.println(Main thread exiting.);}}程序输出如下所示New thread: Thread[One,5,main]New thread: Thread[Two,5,main]New thread: Thread[Three,5,main]Thread One is alive: trueThread Two is alive: trueThread Three is alive: trueWaiting for threads to finish.One: 5Two: 5Three: 5One: 4Two: 4Three: 4One: 3Two: 3Three: 3One: 2Two: 2Three: 2One: 1Two: 1Three: 1Two exiting.Three exiting.One exiting.Thread One is alive: falseThread Two is alive: falseThread Three is alive: falseMain thread exiting.如你所见调用join()后返回线程终止执行。
http://wiki.neutronadmin.com/news/378852/

相关文章:

  • 建设企业网站的公司wordpress会员通知插件
  • 旅游网站的功能装门做特卖的网站
  • 网站开发入门看什么龙岗大运做网站的公司
  • dw制作简单网站模板下载地址浙江省网站建设公司
  • 需要网站开发的吗wordpress 制作网站模板
  • 网站域没到期不能续费吗做网站用突发性实例可以吗
  • 关键字查询我的网站怎么做找建筑网官网
  • 中小企业网站设计开封北京网站建设
  • 网站尺寸大小企业网站源码搜一品资源
  • 天津和平做网站多少钱北京商场营业时间
  • 徐州企业网站设计怎么做加盟网站
  • 俄语培训网站建设沈阳网站制作的公司
  • 上传网站再备案如何自己创造网站
  • 吉林网站建设方案网站用户体验
  • 珠海做网站推广公司网络工程实施方案
  • 景德镇网站维护吴江和城乡建设局网站
  • 外链推广网站重庆seo排名优化费用
  • 辽宁网站建设熊掌号公司的分类
  • 大学生做家教比较好的网站淘宝网免费素材图库
  • 网站制作品牌公司wordpress生成海报图片插件
  • 最贵网站建设多少钱做自媒体好还是网站好
  • 一站式平台网站开发技术wordpress杂志主题nana
  • 网销可以做推广的网站wordpress数据库查询数据库
  • 网站建设教育类旧式网站公司网站建设方案书怎么写
  • 邵阳 做网站公司赣州住房和建设局网站
  • 住房与城乡建设部网站 黑龙江网站品牌建设建议
  • 网站开发常用标签有什么免费做h5的素材网站
  • 网站开发器wordpress海报生成器
  • 多终端网站手机wap网站大全
  • 深圳做网站得外包公司有哪些局网站建设总结