mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
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:
parent
b5d204c3a4
commit
35cb303a2c
7 changed files with 130 additions and 19 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1994, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1994, 2023, 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
|
||||
|
@ -226,8 +226,15 @@ public class Thread implements Runnable {
|
|||
registerNatives();
|
||||
}
|
||||
|
||||
/* Reserved for exclusive use by the JVM, maybe move to FieldHolder */
|
||||
private long eetop;
|
||||
/*
|
||||
* Reserved for exclusive use by the JVM. Cannot be moved to the FieldHolder
|
||||
* as it needs to be set by the VM for JNI attaching threads, before executing
|
||||
* the constructor that will create the FieldHolder. The historically named
|
||||
* `eetop` holds the address of the underlying VM JavaThread, and is set to
|
||||
* non-zero when the thread is started, and reset to zero when the thread terminates.
|
||||
* A non-zero value indicates this thread isAlive().
|
||||
*/
|
||||
private volatile long eetop;
|
||||
|
||||
// thread id
|
||||
private final long tid;
|
||||
|
@ -1840,9 +1847,8 @@ public class Thread implements Runnable {
|
|||
* This method is non-final so it can be overridden.
|
||||
*/
|
||||
boolean alive() {
|
||||
return isAlive0();
|
||||
return eetop != 0;
|
||||
}
|
||||
private native boolean isAlive0();
|
||||
|
||||
/**
|
||||
* Throws {@code UnsupportedOperationException}.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue