Fix races in thread list Unregister.

First race:
We were releasing the thin_lock_id in Unregister before the thread
was not suspended. This could cause problems in
SuspendThreadByThreadId since there was a small window of time where
two threads could share the same thread id. This race caused an
occasional check failure in SuspendThreadByThreadId.

Second race:
We were setting the thin_lock_thread_id_ to 0 in Unregister before
waiting to not be suspended. This caused another race in
SuspendThreadByThreadId where we modified the thread suspend count,
busy waited, but didn't find the thread the next iteration. This
meant that we were returning null even though we had modified the
suspend count. This caused the suspend count to not get decremented
since the caller didn't know that the suspend count had been
increased. Removing the self->thin_lock_thread_id_ = 0 in
ThreadList::UnRegister fixes this race.

Added a bit of additional checks and logging to prevent these issues
from resurfacing, other misc cleanup.

Added thread names to threads in ThreadStress.

Bug: 11319866

Change-Id: I48e3a0700193b72079e450be1e924a2f88cf52e2
diff --git a/test/ThreadStress/ThreadStress.java b/test/ThreadStress/ThreadStress.java
index 8d8135d..795c790 100644
--- a/test/ThreadStress/ThreadStress.java
+++ b/test/ThreadStress/ThreadStress.java
@@ -128,13 +128,13 @@
         Thread[] runners = new Thread[numberOfThreads];
         for (int r = 0; r < runners.length; r++) {
             final ThreadStress ts = threadStresses[r];
-            runners[r] = new Thread() {
+            runners[r] = new Thread("Runner thread " + r) {
                 final ThreadStress threadStress = ts;
                 public void run() {
                     int id = threadStress.id;
-                    System.out.println("Starting runner for " + id);
+                    System.out.println("Starting worker for " + id);
                     while (threadStress.nextOperation < operationsPerThread) {
-                        Thread thread = new Thread(ts);
+                        Thread thread = new Thread(ts, "Worker thread " + id);
                         thread.start();
                         try {
                             thread.join();
@@ -144,14 +144,14 @@
                                            + (operationsPerThread - threadStress.nextOperation)
                                            + " operations remaining.");
                     }
-                    System.out.println("Finishing runner for " + id);
+                    System.out.println("Finishing worker for " + id);
                 }
             };
         }
 
         // The notifier thread is a daemon just loops forever to wake
         // up threads in Operation.WAIT
-        Thread notifier = new Thread() {
+        Thread notifier = new Thread("Notifier") {
             public void run() {
                 while (true) {
                     synchronized (lock) {