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

Commit f86d2fb4 authored by Eugene Susla's avatar Eugene Susla Committed by Gerrit Code Review
Browse files

Merge "Prevent HandlerThread from losing interrupted flag"

parents ca0ddfb7 be9f42d8
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;
    }