Skip to content

Commit

Permalink
More efficient main thread detection
Browse files Browse the repository at this point in the history
  • Loading branch information
topjohnwu committed Jun 2, 2022
1 parent 8ef7539 commit 979cb2b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion core/src/main/java/com/topjohnwu/superuser/ShellUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public static boolean fastCmdResult(Shell shell, String... cmds) {
* @return {@code true} if the current thread is the main thread.
*/
public static boolean onMainThread() {
return ((Looper.myLooper() != null) && (Looper.myLooper() == Looper.getMainLooper()));
return Looper.getMainLooper().getThread() == Thread.currentThread();
}

/**
Expand Down

0 comments on commit 979cb2b

Please sign in to comment.