文件名称:MultiThread

  • 所属分类:
  • JSP源码/Java
  • 资源属性:
  • [Java] [源码]
  • 上传时间:
  • 2012-11-26
  • 文件大小:
  • 1kb
  • 下载次数:
  • 0次
  • 提 供 者:
  • le***
  • 相关连接:
  • 下载说明:
  • 别用迅雷下载,失败请重下,重下不扣分!

介绍说明--下载内容均来自于网络,请自行研究使用

程序中创建了主程序线程、thread1和thread2三个线程,thread1是ThreadUseExtends类的对象,通过继承Thread实现线程,thread2是ThreadUseRunnable类的对象,通过实现Runnable接口实现线程,主程序主线程睡眠7秒,thread1线程睡眠10秒,thread2睡眠1秒,程序执行过程中首先执行主线程,由主线程启动thread1,thread1启动后,需要睡眠10秒,接着主线程睡眠7秒,那么势必主线程醒来时thread1还处于睡眠状态,所以thread1被杀掉了。接着主线程启动thread2,thread2启动后,需要睡眠1秒,接着主线程睡眠7秒,那么当主线程醒来时thread2已经醒来并执行完成,所以主线程没有发现thread2。-Program to create the main program threads, thread1 and thread2 three Thread, thread1 is ThreadUseExtends objects of a class, through inheritance Thread realize Thread, thread2 is ThreadUseRunnable objects of a class, by implementing Runnable interface implementation Thread, the main program main Thread to sleep 7 seconds and thread1 Thread to sleep 10 seconds, thread2 sleep 1 second, during the execution of the first executive main Thread, the main Thread start thread1, thread1 start, need sleep 10 seconds, then the main Thread to sleep 7 seconds, then the main Thread will wake up thread1 is still in a state of sleep, so thread1 was killed. Then the main thread start thread2, thread2 start, need sleep 1 second, then the main thread to sleep 7 seconds and then when main thread woke up thread2 have to wake up and the implementation of the completion, so the main thread found no thread2.




(系统自动生成,下载前可以参看下载内容)

下载文件列表

MultiThread\MultiThread.java

MultiThread

相关说明

  • 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
  • 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度更多...
  • 请直接用浏览器下载本站内容,不要使用迅雷之类的下载软件,用WinRAR最新版进行解压.
  • 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
  • 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
  • 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.

相关评论

暂无评论内容.

发表评论

*主  题:
*内  容:
*验 证 码:

源码中国 www.ymcn.org