--- old/src/share/vm/runtime/java.cpp Wed Feb 18 09:38:18 2015 +++ new/src/share/vm/runtime/java.cpp Wed Feb 18 09:38:18 2015 @@ -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 @@ -422,9 +422,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()) {