Ensure that we don't overwrite suspension target thread

Thanks to Ivan Maidanski for noticing this issue.

Contributed-By: Ivan Maidanski <i.maidanski@samsung.com>
Test: ./test.py --host -j40
Change-Id: I826e3770645ecaedd8a4c5e5201747010ddcf550
diff --git a/runtime/openjdkjvmti/ti_thread.cc b/runtime/openjdkjvmti/ti_thread.cc
index f16b419..9acea2a 100644
--- a/runtime/openjdkjvmti/ti_thread.cc
+++ b/runtime/openjdkjvmti/ti_thread.cc
@@ -701,7 +701,7 @@
 
 jvmtiError ThreadUtil::SuspendOther(art::Thread* self,
                                     jthread target_jthread,
-                                    art::Thread* target) {
+                                    const art::Thread* target) {
   // Loop since we need to bail out and try again if we would end up getting suspended while holding
   // the user_code_suspension_lock_ due to a SuspendReason::kForUserCode. In this situation we
   // release the lock, wait to get resumed and try again.
@@ -729,12 +729,12 @@
       if (state == art::ThreadState::kTerminated || state == art::ThreadState::kStarting) {
         return ERR(THREAD_NOT_ALIVE);
       }
-      target = art::Runtime::Current()->GetThreadList()->SuspendThreadByPeer(
+      art::Thread* ret_target = art::Runtime::Current()->GetThreadList()->SuspendThreadByPeer(
           target_jthread,
           /* request_suspension */ true,
           art::SuspendReason::kForUserCode,
           &timeout);
-      if (target == nullptr && !timeout) {
+      if (ret_target == nullptr && !timeout) {
         // TODO It would be good to get more information about why exactly the thread failed to
         // suspend.
         return ERR(INTERNAL);
diff --git a/runtime/openjdkjvmti/ti_thread.h b/runtime/openjdkjvmti/ti_thread.h
index d07dc06..0f7e837 100644
--- a/runtime/openjdkjvmti/ti_thread.h
+++ b/runtime/openjdkjvmti/ti_thread.h
@@ -98,7 +98,9 @@
   // cause the thread to wake up if the thread is suspended for the debugger or gc or something.
   static jvmtiError SuspendSelf(art::Thread* self)
       REQUIRES(!art::Locks::mutator_lock_, !art::Locks::user_code_suspension_lock_);
-  static jvmtiError SuspendOther(art::Thread* self, jthread target_jthread, art::Thread* target)
+  static jvmtiError SuspendOther(art::Thread* self,
+                                 jthread target_jthread,
+                                 const art::Thread* target)
       REQUIRES(!art::Locks::mutator_lock_, !art::Locks::user_code_suspension_lock_);
 
   static art::ArtField* context_class_loader_;