File tree 1 file changed +9
-3
lines changed
src/java.base/share/classes/jdk/internal/ref
1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright (c) 2015, 2024 , Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 2015, 2025 , Oracle and/or its affiliates. All rights reserved.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
@@ -135,8 +135,14 @@ public void run() {
135
135
mlThread .eraseThreadLocals ();
136
136
}
137
137
try {
138
- // Wait for a Ref, with a timeout to avoid getting hung
139
- // due to a race with clear/clean
138
+ // Wait for a Ref, with a timeout to avoid a potential hang.
139
+ // The Cleaner may become unreachable and its cleanable run,
140
+ // while there are registered cleanables for other objects.
141
+ // If the application explicitly calls clean() on all remaining
142
+ // Cleanables, there won't be any references enqueued to unblock
143
+ // this. Using a timeout is simpler than unblocking this by
144
+ // having cleaning of the last registered cleanable enqueue a
145
+ // dummy reference.
140
146
Cleanable ref = (Cleanable ) queue .remove (60 * 1000L );
141
147
if (ref != null ) {
142
148
ref .clean ();
You can’t perform that action at this time.
0 commit comments