From dc23abbc03d0e911341da0aff85b699dad0c71b2 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Tue, 1 Apr 2014 15:02:13 +0100 Subject: [PATCH] Bug 940575 - Handle null background thread in isOnBackgroundThread() (r=rnewman) --- mobile/android/base/util/ThreadUtils.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mobile/android/base/util/ThreadUtils.java b/mobile/android/base/util/ThreadUtils.java index 48c8657d0c6d..1f2619338b39 100644 --- a/mobile/android/base/util/ThreadUtils.java +++ b/mobile/android/base/util/ThreadUtils.java @@ -23,8 +23,8 @@ public final class ThreadUtils { THROW, } - private static Thread sUiThread; - private static Thread sBackgroundThread; + private static volatile Thread sUiThread; + private static volatile Thread sBackgroundThread; private static Handler sUiHandler; @@ -158,6 +158,10 @@ public final class ThreadUtils { } public static boolean isOnBackgroundThread() { + if (sBackgroundThread == null) { + return false; + } + return isOnThread(sBackgroundThread); }