今天学习线程的时候,想查看start()方法的源码就是下载不下来,无奈网上百度了下,找到了解决的方式:
1.如何在ecplise中查看源代码的尼
2.步骤
点击window->perferences->java->Installed->JRE,然后双击你的JRE
然后就选择rt.jar的那个,
死的,就是这么简单,但是我刚开始选择了External Folder 并没有出现src.zip,
之后就选择了上面的External File , JDK 下的src.zip出现了。
操作完成之后,我就开始愉快的看源码了。快捷键F3,也可以使用Ctrl+鼠标
public synchronized void start() {
/**
* This method is not invoked for the main method thread or "system"
* group threads created/set up by the VM. Any new functionality added
* to this method in the future may have to also be added to the VM.
*
* A zero status value corresponds to state "NEW".
*/
if (threadStatus != 0)
throw new IllegalThreadStateException();
/* Notify the group that this thread is about to be started
* so that it can be added to the group's list of threads
* and the group's unstarted count can be decremented. */
group.add(this);
boolean started = false;
try {
start0(); //此处是重点
started = true;
} finally {
try {
if (!started) {
group.threadStartFailed(this);
}
} catch (Throwable ignore) {
/* do nothing. If start0 threw a Throwable then
it will be passed up the call stack */
}
}
}