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

Commit 9cdea35a authored by Eugene Susla's avatar Eugene Susla Committed by Automerger Merge Worker
Browse files

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

Change-Id: I8277cd9ce4a5ad03228ed8f351acd3d0e7892fdc
parents 340d502b f86d2fb4
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;
    }