D:\demo>javac methodtest.java -deprecation methodtest.java:18: warning: suspend() in java.lang.Thread has been deprecated suspend(); ^ methodtest.java:32: warning: resume() in java.lang.Thread has been deprecated second.resume(); ^ 2 warnings------------------------------------- have been deprecated !
下面的描述或许对你有用(摘自《Sun认证Java2程序员学习指南》): <Transitioning between Thread states >
It is in the running state that most things of interest happen to threads. They execute their run() methods concurrently with other threads, they co-operate, share resources, and they even compete with each other to get their own tasks done.
Because instructions can be performed only one at a time in a single CPU computer, threads have to take turns running. Usually the threads are switching so fast between one another that the user gets the impression of true parallelism (we will discuss this more in the scheduling section of this chapter). For the moment, remember that there is never a guarantee that a thread will execute a series of instructions in one go; it may be switched at any time and get its turn later. If there is more than one CPU available, threads may truly run in parallel.
Once a thread is started, it is not guaranteed to be running all the time. The Java virtual machine (JVM) could switch over to another thread and execute it for a while, giving it some CPU time. These various states are standard Java terms used to describe the state of a thread at any given time during execution. There are essentially five states a thread can be in: new Thread,Runnable,Running,Waiting/Blocking,Dead. --------------------------------------------------------------- 应该讲得很清楚,在second.start()之后,first和second实际上还没有达到Running状态,CPU继续被Main()方法占有,所以先输出的是Waiting for... 至于CPU的分配,则和系统有关。
================================================================CSDN 论坛助手 Ver 1.0 B0402提供下载。 改进了很多,功能完备!★ 浏览帖子速度极快![建议系统使用ie5.5以上]。 ★ 多种帖子实现界面。
★ 保存帖子到本地[html格式]★ 监视您关注帖子的回复更新。
★ 可以直接发贴、回复帖子★ 采用XML接口,可以一次性显示4页帖子,同时支持自定义每次显示帖子数量。可以浏览历史记录!
★ 支持在线检测程序升级情况,可及时获得程序更新的信息。★★ 签名 ●
可以在您的每个帖子的后面自动加上一个自己设计的签名哟。Http://www.ChinaOK.net/csdn/csdn.zip
Http://www.ChinaOK.net/csdn/csdn.rar
Http://www.ChinaOK.net/csdn/csdn.exe [自解压]
methodtest.java:18: warning: suspend() in java.lang.Thread has been deprecated
suspend();
^
methodtest.java:32: warning: resume() in java.lang.Thread has been deprecated
second.resume();
^
2 warnings-------------------------------------
have been deprecated !
<Transitioning between Thread states >
It is in the running state that most things of interest happen to threads. They execute their run() methods concurrently with other threads, they co-operate, share resources, and they even compete with each other to get their own tasks done.
Because instructions can be performed only one at a time in a single CPU computer, threads have to take turns running. Usually the threads are switching so fast between one another that the user gets the impression of true parallelism (we will discuss this more in the scheduling section of this chapter). For the moment, remember that there is never a guarantee that a thread will execute a series of instructions in one go; it may be switched at any time and get its turn later. If there is more than one CPU available, threads may truly run in parallel.
Once a thread is started, it is not guaranteed to be running all the time. The Java virtual machine (JVM) could switch over to another thread and execute it for a while, giving it some CPU time. These various states are standard Java terms used to describe the state of a thread at any given time during execution. There are essentially five states a thread can be in: new Thread,Runnable,Running,Waiting/Blocking,Dead.
---------------------------------------------------------------
应该讲得很清楚,在second.start()之后,first和second实际上还没有达到Running状态,CPU继续被Main()方法占有,所以先输出的是Waiting for...
至于CPU的分配,则和系统有关。