文件名称: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
MultiThread