Skip to content

Commit

Permalink
Clear vmthread from thread object at shutdown
Browse files Browse the repository at this point in the history
Related to: eclipse-openj9/openj9#16659

Signed-off-by: tajila <[email protected]>
  • Loading branch information
tajila committed Oct 23, 2023
1 parent 9e00546 commit 2a71b98
Showing 1 changed file with 24 additions and 21 deletions.
45 changes: 24 additions & 21 deletions src/java.base/share/classes/java/lang/Thread.java
Original file line number Diff line number Diff line change
Expand Up @@ -1614,32 +1614,35 @@ void clearReferences() {
* a chance to clean up before it actually exits.
*/
void exit() {
/* Refresh interrupted value so it is accurate when thread reference is removed. */
interrupted = interrupted();

try {
// pop any remaining scopes from the stack, this may block
if (headStackableScopes != null) {
StackableScope.popAll();
}
} finally {
// notify container that thread is exiting
ThreadContainer container = threadContainer();
if (container != null) {
container.onExit(this);
/* Refresh interrupted value so it is accurate when thread reference is removed. */
interrupted = interrupted();

try {
// pop any remaining scopes from the stack, this may block
if (headStackableScopes != null) {
StackableScope.popAll();
}
} finally {
// notify container that thread is exiting
ThreadContainer container = threadContainer();
if (container != null) {
container.onExit(this);
}
}
}

try {
if (threadLocals != null && TerminatingThreadLocal.REGISTRY.isPresent()) {
TerminatingThreadLocal.threadTerminated();
try {
if (threadLocals != null && TerminatingThreadLocal.REGISTRY.isPresent()) {
TerminatingThreadLocal.threadTerminated();
}
} finally {
clearReferences();
}
} finally {
clearReferences();
}
synchronized (interruptLock) {
// so that isAlive() can work
eetop = Thread.NO_REF;
synchronized (interruptLock) {
// so that isAlive() can work
eetop = Thread.NO_REF;
}
}
}

Expand Down

0 comments on commit 2a71b98

Please sign in to comment.