--- old/src/hotspot/share/runtime/vm_operations.cpp Wed Nov 8 08:13:28 2017 +++ new/src/hotspot/share/runtime/vm_operations.cpp Wed Nov 8 08:13:27 2017 @@ -148,11 +148,10 @@ void VM_DeoptimizeAll::doit() { DeoptimizationMarker dm; - ThreadsListHandle tlh; - JavaThreadIterator jti(tlh.list()); + JavaThreadIteratorWithHandle jtiwh; // deoptimize all java threads in the system if (DeoptimizeALot) { - for (JavaThread* thread = jti.first(); thread != NULL; thread = jti.next()) { + for (; JavaThread *thread = jtiwh.next(); ) { if (thread->has_last_Java_frame()) { thread->deoptimize(); } @@ -163,7 +162,7 @@ int tnum = os::random() & 0x3; int fnum = os::random() & 0x3; int tcount = 0; - for (JavaThread* thread = jti.first(); thread != NULL; thread = jti.next()) { + for (; JavaThread *thread = jtiwh.next(); ) { if (thread->has_last_Java_frame()) { if (tcount++ == tnum) { tcount = 0; @@ -425,9 +424,7 @@ _shutdown_thread = thr_cur; _vm_exited = true; // global flag - ThreadsListHandle tlh; - JavaThreadIterator jti(tlh.list()); - for (JavaThread *thr = jti.first(); thr != NULL; thr = jti.next()) { + for (JavaThreadIteratorWithHandle jtiwh; JavaThread *thr = jtiwh.next(); ) { if (thr!=thr_cur && thr->thread_state() == _thread_in_native) { ++num_active; thr->set_terminated(JavaThread::_vm_exited); // per-thread flag @@ -460,13 +457,13 @@ int max_wait = max_wait_compiler_thread; int attempts = 0; - ThreadsListHandle tlh; - JavaThreadIterator jti(tlh.list()); + JavaThreadIteratorWithHandle jtiwh; while (true) { int num_active = 0; int num_active_compiler_thread = 0; - for (JavaThread *thr = jti.first(); thr != NULL; thr = jti.next()) { + jtiwh.rewind(); + for (; JavaThread *thr = jtiwh.next(); ) { if (thr!=thr_cur && thr->thread_state() == _thread_in_native) { num_active++; if (thr->is_Compiler_thread()) {