We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 06e577c commit 23105feCopy full SHA for 23105fe
utilcode/src/main/java/com/blankj/utilcode/util/ThreadUtils.java
@@ -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