线程thread类中的start方法是如何调用到实现runnable接口的类中的run方法的?
我查看了jvm的源代码,但是还是没有找到答案,欢迎大家各抒己见咯!
我查看了jvm的源代码,但是还是没有找到答案,欢迎大家各抒己见咯!
解决方案 »
- spark 插件编译不了。有遇到的吗
- 严重: Servlet.service() for servlet jsp threw exception异常
- 大家帮我解读下JS代码
- 我公司使用自行开发的web系统,调用的是java 1.4,如果只安装java1.5或6的话又不能正常使用,能否把1.5或6的版本设置成web系统认定调用的
- 我现在做一个工作流的程序,我是把数据放在xml中.然后读取数据,并在applet显示出来.
- java小冬冬令我头疼--javax.swing.*; JLabel.setIcon()无法显示图片,,求教哦!~
- 网页插入applet,安装控制台?
- 给高分求助
- 我想编写一个java绘图程序,为了消除锯齿线
- JAVA Socket编程有没有类似C下面的FD_SET(...),select(...)这样的函数?
- 生兔子问题求第三解
- 异常捕捉中的一个问题
public Thread() {
this(null, null, newName());
}
public Thread(Runnable runnable) {
this(null, runnable, newName());
}
public Thread(ThreadGroup group, Runnable runnable, String threadName) {
super();
if (threadName==null) throw new NullPointerException();
this.name = threadName; // We avoid the public API 'setName', since it does redundant work (checkAccess)
this.runnable = runnable; // No API available here, so just direct access to inst. var.
Thread currentThread = currentThread(); this.isDaemon = currentThread.isDaemon(); // We avoid the public API 'setDaemon', since it does redundant work (checkAccess) if (group == null) {
SecurityManager currentManager = System.getSecurityManager();
// if there is a security manager...
if (currentManager != null)
// Ask SecurityManager for ThreadGroup
group = currentManager.getThreadGroup();
}
if (group == null)
// Same group as Thread that created us
group = currentThread.getThreadGroup(); initialize(false, group, currentThread); setPriority(currentThread.getPriority()); // In this case we can call the public API according to the spec - 20.20.10
}public void run() {
if (runnable != null) {
runnable.run();
}
}
public synchronized void start() {
synchronized(lock) {
if (started) {
// K0341 = Thread is already started
throw new IllegalThreadStateException(com.ibm.oti.util.Msg.getString("K0341"));
}
boolean success = false;
threadGroup.add(this);
try {
startImpl();
success = true;
} finally {
if (!success) {
threadGroup.remove(this);
}
}
}
}
private native void startImpl();