How do I check if the current thread is the main thread?

Asked 2 years ago, Updated 2 years ago, 87 views

I need a code to check whether the current thread is the main thread or not, how can I do it

android multithreading java

2022-09-22 11:38

1 Answers

Looper.myLooper() == Looper.getMainLooper()

If the return value is true, it is the main thread.


2022-09-22 11:38

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.