158 |
if (shutdownHooks != null) |
if (shutdownHooks != null) |
159 |
{ |
{ |
160 |
shutdownHooks.remove(Thread.currentThread()); |
shutdownHooks.remove(Thread.currentThread()); |
161 |
// Shutdown hooks are still running, so we clear status to |
// Interrupt the exit sequence thread, in case it was waiting |
162 |
|
// inside a join on our thread. |
163 |
|
exitSequence.interrupt(); |
164 |
|
// Shutdown hooks are still running, so we clear status to |
165 |
// make sure we don't halt. |
// make sure we don't halt. |
166 |
status = 0; |
status = 0; |
167 |
} |
} |
227 |
// itself from the set, then waits indefinitely on the |
// itself from the set, then waits indefinitely on the |
228 |
// exitSequence thread. Once the set is empty, set it to null to |
// exitSequence thread. Once the set is empty, set it to null to |
229 |
// signal all finalizer threads that halt may be called. |
// signal all finalizer threads that halt may be called. |
230 |
while (! shutdownHooks.isEmpty()) |
while (true) |
231 |
{ |
{ |
232 |
Thread[] hooks; |
Thread[] hooks; |
233 |
synchronized (libpath) |
synchronized (libpath) |
235 |
hooks = new Thread[shutdownHooks.size()]; |
hooks = new Thread[shutdownHooks.size()]; |
236 |
shutdownHooks.toArray(hooks); |
shutdownHooks.toArray(hooks); |
237 |
} |
} |
238 |
for (int i = hooks.length; --i >= 0; ) |
if (hooks.length == 0) |
239 |
if (! hooks[i].isAlive()) |
break; |
240 |
synchronized (libpath) |
for (int i = 0; i < hooks.length; i++) |
241 |
|
{ |
242 |
|
try |
243 |
{ |
{ |
244 |
shutdownHooks.remove(hooks[i]); |
synchronized (libpath) |
245 |
|
{ |
246 |
|
if (!shutdownHooks.contains(hooks[i])) |
247 |
|
continue; |
248 |
|
} |
249 |
|
hooks[i].join(); |
250 |
|
synchronized (libpath) |
251 |
|
{ |
252 |
|
shutdownHooks.remove(hooks[i]); |
253 |
|
} |
254 |
} |
} |
255 |
|
catch (InterruptedException x) |
256 |
Thread.yield(); // Give other threads a chance. |
{ |
257 |
|
// continue waiting on the next thread |
258 |
|
} |
259 |
|
} |
260 |
} |
} |
261 |
synchronized (libpath) |
synchronized (libpath) |
262 |
{ |
{ |