Thread.start() 和 Thread.run() 有什么区别? [英] What is the difference between Thread.start() and Thread.run()?
本文介绍了Thread.start() 和 Thread.run() 有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么我们要调用 start()
方法,而后者又调用 run()
方法?
我们不能直接调用 run()
吗?
Why do we call the start()
method, which in turn calls the run()
method?
Can't we directly make a call to run()
?
请举例说明不同之处.
推荐答案
不,你不能.调用run会在同一个线程中执行run()
方法,不会启动新线程.
No, you can't. Calling run will execute run()
method in the same thread, without starting new thread.
这篇关于Thread.start() 和 Thread.run() 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文