Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 58466dd8 authored by Eugene Susla's avatar Eugene Susla Committed by Automerger Merge Worker
Browse files

Merge "Prevent HandlerThread from losing interrupted flag" am: f86d2fb4 am:...

Merge "Prevent HandlerThread from losing interrupted flag" am: f86d2fb4 am: 9cdea35a am: ea5a8302 am: 9ad98ff9

Change-Id: I29dc28906197b98b9cfcd9f08fb79107f433b3a9
parents 88b484a2 9ad98ff9
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -79,15 +79,27 @@ public class HandlerThread extends Thread {
            return null;
        }

        boolean wasInterrupted = false;

        // If the thread has been started, wait until the looper has been created.
        synchronized (this) {
            while (isAlive() && mLooper == null) {
                try {
                    wait();
                } catch (InterruptedException e) {
                    wasInterrupted = true;
                }
            }
        }

        /*
         * We may need to restore the thread's interrupted flag, because it may
         * have been cleared above since we eat InterruptedExceptions
         */
        if (wasInterrupted) {
            Thread.currentThread().interrupt();
        }

        return mLooper;
    }