RFR: 8344337: SecurityManager cleanup in java.prefs module [v5]

Alan Bateman alanb at openjdk.org
Fri Nov 22 07:20:16 UTC 2024


On Thu, 21 Nov 2024 20:46:47 GMT, Brent Christian <bchristi at openjdk.org> wrote:

>> src/java.prefs/unix/classes/java/util/prefs/FileSystemPreferences.java line 451:
>> 
>>> 449:         // Add shutdown hook to flush cached prefs on normal termination
>>> 450:         Runtime.getRuntime().addShutdownHook(
>>> 451:             new Thread(null, null, "Sync Timer Thread", 0, false) {
>> 
>> Future work, use a Virtual thread for this.
>
> https://bugs.openjdk.org/browse/JDK-8344793

I'm not sure that this make sense. A shutdown hook is an unstarted Thread so it's not bound to an OS thread at this point. Main issue with using a virtual thread as a shutdown hook is that it might be the first usage of virtual threads and so it would be starting a new carrier to run this really short lived task to cancel the timer.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/22252#discussion_r1853389835


More information about the core-libs-dev mailing list