Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Commit

Permalink
Merge "Retry if interrupted before mMessageThread has joined."
Browse files Browse the repository at this point in the history
  • Loading branch information
miaowang14 authored and Gerrit Code Review committed Oct 5, 2015
2 parents ea6952c + 2acc30f commit 4d70a80
Showing 1 changed file with 15 additions and 3 deletions.
Expand Up @@ -1645,9 +1645,21 @@ public void destroy() {
}
nContextDeinitToClient(mContext);
mMessageThread.mRun = false;
try {
mMessageThread.join();
} catch(InterruptedException e) {

// Wait for mMessageThread to join. Try in a loop, in case this thread gets interrupted
// during the wait. If interrupted, set the "interrupted" status of the current thread.
boolean hasJoined = false, interrupted = false;
while (!hasJoined) {
try {
mMessageThread.join();
hasJoined = true;
} catch (InterruptedException e) {
interrupted = true;
}
}
if (interrupted) {
Log.v(LOG_TAG, "Interrupted during wait for MessageThread to join");
Thread.currentThread().interrupt();
}

nContextDestroy();
Expand Down

0 comments on commit 4d70a80

Please sign in to comment.