Index: webrtc/base/java/src/org/webrtc/ThreadUtils.java |
diff --git a/webrtc/base/java/src/org/webrtc/ThreadUtils.java b/webrtc/base/java/src/org/webrtc/ThreadUtils.java |
index 4337fd0349c1638cb6f4a31914a283b71171fbbc..efe1fbd884507758ad54e7c270c3d9b2faf731d8 100644 |
--- a/webrtc/base/java/src/org/webrtc/ThreadUtils.java |
+++ b/webrtc/base/java/src/org/webrtc/ThreadUtils.java |
@@ -11,6 +11,7 @@ |
package org.webrtc; |
import android.os.Handler; |
+import android.os.Looper; |
import android.os.SystemClock; |
import java.util.concurrent.Callable; |
@@ -39,6 +40,15 @@ public class ThreadUtils { |
} |
/** |
+ * Throws exception if called from other than main thread. |
+ */ |
+ public static void checkIsOnMainThread() { |
+ if (Thread.currentThread() != Looper.getMainLooper().getThread()) { |
+ throw new IllegalStateException("Not on main thread!"); |
+ } |
+ } |
+ |
+ /** |
* Utility interface to be used with executeUninterruptibly() to wait for blocking operations |
* to complete without getting interrupted.. |
*/ |