diff --git a/indra/llcommon/llthread.cpp b/indra/llcommon/llthread.cpp
index a4171729dbb8db1805e80ca1dc198b182c58f243..f875e4e0dc35e2bb8deb48f34950e62c080f9ac8 100644
--- a/indra/llcommon/llthread.cpp
+++ b/indra/llcommon/llthread.cpp
@@ -97,14 +97,34 @@ U32 LL_THREAD_LOCAL sThreadID = 0;
 
 U32 LLThread::sIDIter = 0;
 
+namespace
+{
+
+    U32 main_thread()
+    {
+        // Using a function-static variable to identify the main thread
+        // requires that control reach here from the main thread before it
+        // reaches here from any other thread. We simply trust that whichever
+        // thread gets here first is the main thread.
+        static U32 s_thread_id = LLThread::currentID();
+        return s_thread_id;
+    }
+
+} // anonymous namespace
+
+LL_COMMON_API bool on_main_thread()
+{
+    return (LLThread::currentID() == main_thread());
+}
 
 LL_COMMON_API void assert_main_thread()
 {
-    static U32 s_thread_id = LLThread::currentID();
-    if (LLThread::currentID() != s_thread_id)
+    auto curr = LLThread::currentID();
+    auto main = main_thread();
+    if (curr != main)
     {
-        LL_WARNS() << "Illegal execution from thread id " << (S32) LLThread::currentID()
-            << " outside main thread " << (S32) s_thread_id << LL_ENDL;
+        LL_WARNS() << "Illegal execution from thread id " << curr
+            << " outside main thread " << main << LL_ENDL;
     }
 }
 
diff --git a/indra/llcommon/llthread.h b/indra/llcommon/llthread.h
index 863c9051f38cb5edf5a959eb60ef09a16a69d82d..37f6e66bbb8f73e2ed593327de1171d778b27e5f 100644
--- a/indra/llcommon/llthread.h
+++ b/indra/llcommon/llthread.h
@@ -34,8 +34,6 @@
 #include "llrefcount.h"
 #include <thread>
 
-LL_COMMON_API void assert_main_thread();
-
 namespace LLTrace
 {
     class ThreadRecorder;
@@ -168,5 +166,6 @@ class LL_COMMON_API LLResponder : public LLThreadSafeRefCount
 //============================================================================
 
 extern LL_COMMON_API void assert_main_thread();
+extern LL_COMMON_API bool on_main_thread();
 
 #endif // LL_LLTHREAD_H