summaryrefslogtreecommitdiffstats
path: root/rs
diff options
context:
space:
mode:
authorPirama Arumuga Nainar <pirama@google.com>2015-10-02 16:38:08 -0700
committerPirama Arumuga Nainar <pirama@google.com>2015-10-08 20:14:51 -0700
commit1078942ed8b4029665e950ae576baa024f69e782 (patch)
tree9967be0db8aa7c219e08b2fbc2cb9c14fd634b30 /rs
parent93db3d4bfd0062024a0cc05623e7e84df7313d86 (diff)
downloadframeworks_base-1078942ed8b4029665e950ae576baa024f69e782.zip
frameworks_base-1078942ed8b4029665e950ae576baa024f69e782.tar.gz
frameworks_base-1078942ed8b4029665e950ae576baa024f69e782.tar.bz2
Safely handle interrupts during Thread.join()
Bug: 24342101 Interrupt current thread if InterruptedException is received during Thread.join(). Also, log the interruption. Change-Id: I452124915ea3f19610e6d4a3411d741f2f604af2 (cherry picked from commit 83461d73bc50d41f631e1db5c195d12b4eb9e6cf)
Diffstat (limited to 'rs')
-rw-r--r--rs/java/android/renderscript/RenderScript.java11
1 files changed, 8 insertions, 3 deletions
diff --git a/rs/java/android/renderscript/RenderScript.java b/rs/java/android/renderscript/RenderScript.java
index 62ddc39..4440417 100644
--- a/rs/java/android/renderscript/RenderScript.java
+++ b/rs/java/android/renderscript/RenderScript.java
@@ -1559,15 +1559,20 @@ public class RenderScript {
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();