3627 { MutexLocker nu(Threads_lock);
3628 while (Threads::number_of_non_daemon_threads() > 1 )
3629 // This wait should make safepoint checks, wait without a timeout,
3630 // and wait as a suspend-equivalent condition.
3631 //
3632 // Note: If the FlatProfiler is running and this thread is waiting
3633 // for another non-daemon thread to finish, then the FlatProfiler
3634 // is waiting for the external suspend request on this thread to
3635 // complete. wait_for_ext_suspend_completion() will eventually
3636 // timeout, but that takes time. Making this wait a suspend-
3637 // equivalent condition solves that timeout problem.
3638 //
3639 Threads_lock->wait(!Mutex::_no_safepoint_check_flag, 0,
3640 Mutex::_as_suspend_equivalent_flag);
3641 }
3642
3643 // Hang forever on exit if we are reporting an error.
3644 if (ShowMessageBoxOnError && is_error_reported()) {
3645 os::infinite_sleep();
3646 }
3647
3648 if (JDK_Version::is_jdk12x_version()) {
3649 // We are the last thread running, so check if finalizers should be run.
3650 // For 1.3 or later this is done in thread->invoke_shutdown_hooks()
3651 HandleMark rm(thread);
3652 Universe::run_finalizers_on_exit();
3653 } else {
3654 // run Java level shutdown hooks
3655 thread->invoke_shutdown_hooks();
3656 }
3657
3658 before_exit(thread);
3659
3660 thread->exit(true);
3661
3662 // Stop VM thread.
3663 {
3664 // 4945125 The vm thread comes to a safepoint during exit.
3665 // GC vm_operations can get caught at the safepoint, and the
3666 // heap is unparseable if they are caught. Grab the Heap_lock
|
3627 { MutexLocker nu(Threads_lock);
3628 while (Threads::number_of_non_daemon_threads() > 1 )
3629 // This wait should make safepoint checks, wait without a timeout,
3630 // and wait as a suspend-equivalent condition.
3631 //
3632 // Note: If the FlatProfiler is running and this thread is waiting
3633 // for another non-daemon thread to finish, then the FlatProfiler
3634 // is waiting for the external suspend request on this thread to
3635 // complete. wait_for_ext_suspend_completion() will eventually
3636 // timeout, but that takes time. Making this wait a suspend-
3637 // equivalent condition solves that timeout problem.
3638 //
3639 Threads_lock->wait(!Mutex::_no_safepoint_check_flag, 0,
3640 Mutex::_as_suspend_equivalent_flag);
3641 }
3642
3643 // Hang forever on exit if we are reporting an error.
3644 if (ShowMessageBoxOnError && is_error_reported()) {
3645 os::infinite_sleep();
3646 }
3647 os::check_for_debugger_and_wait();
3648
3649 if (JDK_Version::is_jdk12x_version()) {
3650 // We are the last thread running, so check if finalizers should be run.
3651 // For 1.3 or later this is done in thread->invoke_shutdown_hooks()
3652 HandleMark rm(thread);
3653 Universe::run_finalizers_on_exit();
3654 } else {
3655 // run Java level shutdown hooks
3656 thread->invoke_shutdown_hooks();
3657 }
3658
3659 before_exit(thread);
3660
3661 thread->exit(true);
3662
3663 // Stop VM thread.
3664 {
3665 // 4945125 The vm thread comes to a safepoint during exit.
3666 // GC vm_operations can get caught at the safepoint, and the
3667 // heap is unparseable if they are caught. Grab the Heap_lock
|