--- old/src/os/windows/vm/os_windows.cpp 2014-08-19 01:13:54.323120903 +0400 +++ new/src/os/windows/vm/os_windows.cpp 2014-08-19 01:13:54.223072160 +0400 @@ -410,6 +410,8 @@ LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo); +extern int volatile vm_getting_terminated; + // Thread start routine for all new Java threads static unsigned __stdcall java_start(Thread* thread) { // Try to randomize the cache line index of hot stack frames. @@ -449,6 +451,13 @@ Atomic::dec_ptr((intptr_t*)&os::win32::_os_thread_count); } + if (vm_getting_terminated && thread->is_Java_thread()) { + JavaThread* java_thread = (JavaThread*)thread; + if (java_thread && java_lang_Thread::is_daemon(java_thread->threadObj())) { + return 70115; + } + } + return 0; } --- old/src/share/vm/runtime/java.cpp 2014-08-19 01:13:54.843374365 +0400 +++ new/src/share/vm/runtime/java.cpp 2014-08-19 01:13:54.739323673 +0400 @@ -441,6 +441,8 @@ } } +int volatile vm_getting_terminated = 0; + // Note: before_exit() can be executed only once, if more than one threads // are trying to shutdown the VM at the same time, only one thread // can run before_exit() and all other threads must wait. @@ -471,6 +473,8 @@ } } + vm_getting_terminated = 1; + // The only difference between this and Win32's _onexit procs is that // this version is invoked before any threads get killed. ExitProc* current = exit_procs;