Safely handle interrupts during Thread.join()

Interrupt current thread if InterruptedException is received during
Thread.join().  Also, log the interruption.

Change-Id: I452124915ea3f19610e6d4a3411d741f2f604af2
diff --git a/rs/java/android/renderscript/RenderScript.java b/rs/java/android/renderscript/RenderScript.java
index c359451..f3b6d3b 100644
--- a/rs/java/android/renderscript/RenderScript.java
+++ b/rs/java/android/renderscript/RenderScript.java
@@ -1576,15 +1576,20 @@
             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();