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

Commit

Permalink
Merge "Safely handle interrupts during Thread.join()"
Browse files Browse the repository at this point in the history
  • Loading branch information
pirama-arumuga-nainar authored and Gerrit Code Review committed Oct 5, 2015
2 parents bd57dac + 83461d7 commit 46b5109
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions rs/java/android/renderscript/RenderScript.java
Expand Up @@ -1576,15 +1576,20 @@ private void helpDestroy() {
mMessageThread.mRun = false;

// Wait for mMessageThread to join. Try in a loop, in case this thread gets interrupted
// during the wait.
boolean hasJoined = false;
// 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) {
} 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 46b5109

Please sign in to comment.