Fix a CC deadlock in 129-ThreadGetId.

GC should consider a thread as "waiting for GC thread flip" or
"transitioning to runnable" only if its suspend count is 1.

See 31683379#7 for the deadlock scenario.

Bug: 31683379
Bug: 12687968
Test: test-art with CC and gcstress, N9 libartd boot, Ritz EAAC.
Change-Id: Icd2548bd6d9a4f8d7b54ed20150a4801af9e26a3
diff --git a/runtime/thread_list.cc b/runtime/thread_list.cc
index 5e6c8a4..045e62a 100644
--- a/runtime/thread_list.cc
+++ b/runtime/thread_list.cc
@@ -441,8 +441,8 @@
       // runnable (both cases waiting inside Thread::TransitionFromSuspendedToRunnable), or waiting
       // for the thread flip to end at the JNI critical section entry (kWaitingForGcThreadFlip),
       ThreadState state = thread->GetState();
-      if (state == kWaitingForGcThreadFlip ||
-          thread->IsTransitioningToRunnable()) {
+      if ((state == kWaitingForGcThreadFlip || thread->IsTransitioningToRunnable()) &&
+          thread->GetSuspendCount() == 1) {
         // The thread will resume right after the broadcast.
         thread->ModifySuspendCount(self, -1, nullptr, false);
         ++runnable_thread_count;