--- 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()) {