为什么start方法才能启动线程,而run不行?
我们都知道,一个线程直接对应了一个Thread对象,在刚开始学习线程的时候我们也知道启动线程是通过start()方法,而并非run()方法。
那这是为什么呢?
如果你熟悉Thread的代码的话,你应该知道在这个类加载的时候会注册一些native方法
public
classThreadimplementsRunnable{
/*MakesureregisterNativesisthefirstthing<clinit>does.*/
privates...
原创
2020-08-08 20:40:13 ·
308 阅读 ·
0 评论