Skip to content

Commit 23105fe

Browse files
committed
see 05/18 log
1 parent 06e577c commit 23105fe

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.blankj.utilcode.util;
2+
3+
import android.os.Looper;
4+
5+
/**
6+
* <pre>
7+
* author: Blankj
8+
* blog : http://blankj.com
9+
* time : 2018/05/17
10+
* desc :
11+
* </pre>
12+
*/
13+
public class ThreadUtils {
14+
15+
/**
16+
* Returns {@code true} if called on the main thread, {@code false} otherwise.
17+
*/
18+
public static boolean isOnMainThread() {
19+
return Looper.myLooper() == Looper.getMainLooper();
20+
}
21+
22+
/**
23+
* Returns {@code true} if called on a background thread, {@code false} otherwise.
24+
*/
25+
public static boolean isOnBackgroundThread() {
26+
return !isOnMainThread();
27+
}
28+
29+
30+
}

0 commit comments

Comments
 (0)