hotspot/src/share/vm/runtime/java.cpp
changeset 29321 b7582a690cb9
parent 29208 b570d043f295
child 30558 baec90a2699f
--- a/hotspot/src/share/vm/runtime/java.cpp	Mon Mar 02 05:32:01 2015 -0800
+++ b/hotspot/src/share/vm/runtime/java.cpp	Mon Mar 02 16:31:25 2015 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -421,9 +421,11 @@
     os::infinite_sleep();
   }
 
-  // Terminate watcher thread - must before disenrolling any periodic task
-  if (PeriodicTask::num_tasks() > 0)
+  // Stop the WatcherThread. We do this before disenrolling various
+  // PeriodicTasks to reduce the likelihood of races.
+  if (PeriodicTask::num_tasks() > 0) {
     WatcherThread::stop();
+  }
 
   // Print statistics gathered (profiling ...)
   if (Arguments::has_profile()) {