diff -r 655c5b5f7486 -r bd0d881cf1c5 hotspot/src/share/vm/runtime/thread.hpp --- a/hotspot/src/share/vm/runtime/thread.hpp Mon Nov 05 13:55:31 2012 -0800 +++ b/hotspot/src/share/vm/runtime/thread.hpp Thu Oct 04 14:55:57 2012 +0200 @@ -722,6 +722,7 @@ private: static WatcherThread* _watcher_thread; + static bool _startable; volatile static bool _should_terminate; // updated without holding lock public: enum SomeConstants { @@ -738,6 +739,7 @@ char* name() const { return (char*)"VM Periodic Task Thread"; } void print_on(outputStream* st) const; void print() const { print_on(tty); } + void unpark(); // Returns the single instance of WatcherThread static WatcherThread* watcher_thread() { return _watcher_thread; } @@ -745,6 +747,12 @@ // Create and start the single instance of WatcherThread, or stop it on shutdown static void start(); static void stop(); + // Only allow start once the VM is sufficiently initialized + // Otherwise the first task to enroll will trigger the start + static void make_startable(); + + private: + int sleep() const; };