aboutsummaryrefslogtreecommitdiff
path: root/src/java.base/share/classes/java/lang/Thread.java
diff options
context:
space:
mode:
authorAleksey Shipilev <shade@openjdk.org>2023-06-28 11:50:44 +0000
committerAleksey Shipilev <shade@openjdk.org>2023-06-28 11:50:44 +0000
commit4fd0ee52b3d5fcff1fa54467c2da52daa65d16ce (patch)
tree5a76ff363ae66fa7f734d1be66df114ac93fe98f /src/java.base/share/classes/java/lang/Thread.java
parent8204dfab76d8ae61c2bc68cdf42fcd0fb7a81189 (diff)
downloadopenjdk-4fd0ee52b3d5fcff1fa54467c2da52daa65d16ce.tar.gz
openjdk-4fd0ee52b3d5fcff1fa54467c2da52daa65d16ce.zip
8305425: Thread.isAlive0 doesn't need to call into the VM
Reviewed-by: phh, mdoerr Backport-of: 35cb303a2c0c8b32de257c02e012a1928a6b4594
Diffstat (limited to 'src/java.base/share/classes/java/lang/Thread.java')
-rw-r--r--src/java.base/share/classes/java/lang/Thread.java15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/java.base/share/classes/java/lang/Thread.java b/src/java.base/share/classes/java/lang/Thread.java
index c13b42c2f6f..e1ea45cafc2 100644
--- a/src/java.base/share/classes/java/lang/Thread.java
+++ b/src/java.base/share/classes/java/lang/Thread.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1994, 2021, 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
@@ -157,7 +157,14 @@ public class Thread implements Runnable {
/* Fields reserved for exclusive use by the JVM */
private boolean stillborn = false;
- private long eetop;
+
+ /*
+ * Reserved for exclusive use by the JVM. 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;
/* What will be run. */
private Runnable target;
@@ -1050,7 +1057,9 @@ public class Thread implements Runnable {
* @return {@code true} if this thread is alive;
* {@code false} otherwise.
*/
- public final native boolean isAlive();
+ public final boolean isAlive() {
+ return eetop != 0;
+ }
/**
* Suspends this thread.