8305425: Thread.isAlive0 doesn't need to call into the VM

Co-authored-by: Aleksey Shipilev <shade@openjdk.org>
Reviewed-by: shade, coleenp, alanb
This commit is contained in:
David Holmes 2023-04-05 21:54:38 +00:00
parent b5d204c3a4
commit 35cb303a2c
7 changed files with 130 additions and 19 deletions

View file

@ -739,7 +739,9 @@ static void ensure_join(JavaThread* thread) {
// Thread is exiting. So set thread_status field in java.lang.Thread class to TERMINATED.
java_lang_Thread::set_thread_status(threadObj(), JavaThreadStatus::TERMINATED);
// Clear the native thread instance - this makes isAlive return false and allows the join()
// to complete once we've done the notify_all below
// to complete once we've done the notify_all below. Needs a release() to obey Java Memory Model
// requirements.
OrderAccess::release();
java_lang_Thread::set_thread(threadObj(), nullptr);
lock.notify_all(thread);
// Ignore pending exception, since we are exiting anyway