Thread.start()和Thread.run()有什么区别? [英] What is the difference between Thread.start() and Thread.run()?

查看:181
本文介绍了Thread.start()和Thread.run()有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么我们调用 start()方法,然后调用 run() br>
我们不能直接调用 run()

Why do we call the start() method, which in turn calls the run() method?
Can't we directly make a call to run()?

请给出一个有区别的例子。

Please give an example where there is a difference.

推荐答案

不,你不能。调用运行将在同一个线程中执行run()方法,而不启动新线程。

No, you can't. Calling run will execute run() method in the same thread, without starting new thread.

这篇关于Thread.start()和Thread.run()有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆