Fix at least two deadlocks.

Pretty much every caller that takes the thread list lock can then go on to
cause allocation, which requires the heap lock. The GC always takes the heap
lock first and the thread list lock second (to suspend/resume other threads).
Cue deadlocks.

This patch is a pretty degenerate fix that basically makes the thread list
lock irrelevant; we now always take the heap lock first.

Change-Id: I0537cffb0b841bfb5033789817793734d75dfb31
diff --git a/src/java_lang_Thread.cc b/src/java_lang_Thread.cc
index 891238e..9031471 100644
--- a/src/java_lang_Thread.cc
+++ b/src/java_lang_Thread.cc
@@ -35,7 +35,7 @@
 }
 
 jboolean Thread_isInterrupted(JNIEnv* env, jobject javaThread) {
-  ThreadListLock lock;
+  ScopedThreadListLock thread_list_lock;
   Thread* thread = Thread::FromManagedThread(env, javaThread);
   return (thread != NULL) ? thread->IsInterrupted() : JNI_FALSE;
 }
@@ -46,7 +46,7 @@
 }
 
 jint Thread_nativeGetStatus(JNIEnv* env, jobject javaThread) {
-  ThreadListLock lock;
+  ScopedThreadListLock thread_list_lock;
   Thread* thread = Thread::FromManagedThread(env, javaThread);
   if (thread == NULL) {
     return -1;
@@ -61,13 +61,13 @@
     Thread::Current()->ThrowNewException("Ljava/lang/NullPointerException;", "object == null");
     return JNI_FALSE;
   }
-  ThreadListLock lock;
+  ScopedThreadListLock thread_list_lock;
   Thread* thread = Thread::FromManagedThread(env, javaThread);
   return thread->HoldsLock(object);
 }
 
 void Thread_nativeInterrupt(JNIEnv* env, jobject javaThread) {
-  ThreadListLock lock;
+  ScopedThreadListLock thread_list_lock;
   Thread* thread = Thread::FromManagedThread(env, javaThread);
   if (thread != NULL) {
     thread->Interrupt();
@@ -75,7 +75,7 @@
 }
 
 void Thread_nativeSetName(JNIEnv* env, jobject javaThread, jstring javaName) {
-  ThreadListLock lock;
+  ScopedThreadListLock thread_list_lock;
   Thread* thread = Thread::FromManagedThread(env, javaThread);
   if (thread != NULL) {
     ScopedUtfChars name(env, javaName);
@@ -96,7 +96,7 @@
  * threads at Thread.NORM_PRIORITY (5).
  */
 void Thread_nativeSetPriority(JNIEnv* env, jobject javaThread, jint newPriority) {
-  ThreadListLock lock;
+  ScopedThreadListLock thread_list_lock;
   Thread* thread = Thread::FromManagedThread(env, javaThread);
   if (thread != NULL) {
     thread->SetNativePriority(newPriority);