由网友(半夏微凉。)分享简介:我需要检查,如果运行的某一块code线程的主(UI)线程上运行与否。我怎样才能做到这一点?解决方案 Looper.myLooper()== Looper.getMainLooper()如果返回true,那么你是在UI线程!I need to check if the thread running a certai...![线程概念 线程控制](/d/file/2023/09-17/253d714d7ab4a425dee7b3a299bd4d3a.png)
我需要检查,如果运行的某一块code线程的主(UI)线程上运行与否。我怎样才能做到这一点?
解决方案 Looper.myLooper()== Looper.getMainLooper()
如果返回true,那么你是在UI线程!
I need to check if the thread running a certain piece of code is running on the main (UI) thread or not. How can I achieve this?
解决方案![线程概念 线程控制](/d/file/2023/09-17/253d714d7ab4a425dee7b3a299bd4d3a.png)
Looper.myLooper() == Looper.getMainLooper()
if this returns true, then you're on the UI thread!
相关推荐
最新文章