首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >什么时候你会调用java的thread.run()而不是thread.start()?

什么时候你会调用java的thread.run()而不是thread.start()?
EN

Stack Overflow用户
提问于 2008-11-04 18:21:09
回答 14查看 74.4K关注 0票数 109

什么时候调用Java的thread.run()而不是thread.start()

EN

Stack Overflow用户

发布于 2008-11-04 18:35:20

至少在JVM1.6.中,有一些检查和运行被本机调用:

代码语言:javascript
运行
复制
 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();
        group.add(this);
        start0();
        if (stopBeforeStart) {
        stop0(throwableFromStop);
    }
    }

    private native void start0();
票数 2
EN
查看全部 14 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/262816

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档