开发者

android runnable difference

开发者 https://www.devze.com 2022-12-18 15:01 出处:网络
What is the different b/w running runnable inside handler new Handler().post(runnable) an开发者_运维知识库d running in Thread(runable) ?Handler is used for communication between and coordinating threa

What is the different b/w running runnable inside handler new Handler().post(runnable) an开发者_运维知识库d running in Thread(runable) ?


Handler is used for communication between and coordinating threads. By creating a Handler, you bind it to the current thread. If you post a runnable to that Handler, it will be executed in that same thread.

Thread is Java's way to spawn new user-level threads. The runnable you pass it will be executed in that thread.

The two concepts are not mutually exclusive. You can use Handler with custom Threads.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号