diff src/share/vm/gc_implementation/g1/g1StringDedupThread.cpp @ 17947:1772223a25a2

8037112: gc/g1/TestHumongousAllocInitialMark.java caused SIGSEGV Reviewed-by: brutisso, mgerdin
author pliden
date Fri, 11 Apr 2014 11:00:12 +0200
parents 595c0f60d50d
children 581e70386ec9
line wrap: on
line diff
--- a/src/share/vm/gc_implementation/g1/g1StringDedupThread.cpp	Thu May 22 09:12:29 2014 +0200
+++ b/src/share/vm/gc_implementation/g1/g1StringDedupThread.cpp	Fri Apr 11 11:00:12 2014 +0200
@@ -73,6 +73,9 @@
 
     // Wait for the queue to become non-empty
     G1StringDedupQueue::wait();
+    if (_should_terminate) {
+      break;
+    }
 
     // Include this thread in safepoints
     stsJoin();
@@ -108,7 +111,23 @@
     stsLeave();
   }
 
-  ShouldNotReachHere();
+  terminate();
+}
+
+void G1StringDedupThread::stop() {
+  {
+    MonitorLockerEx ml(Terminator_lock);
+    _thread->_should_terminate = true;
+  }
+
+  G1StringDedupQueue::cancel_wait();
+
+  {
+    MonitorLockerEx ml(Terminator_lock);
+    while (!_thread->_has_terminated) {
+      ml.wait();
+    }
+  }
 }
 
 void G1StringDedupThread::print(outputStream* st, const G1StringDedupStat& last_stat, const G1StringDedupStat& total_stat) {