RFR: 8344332: (bf) Migrate DirectByteBuffer away from jdk.internal.ref.Cleaner [v6]

Brent Christian bchristi at openjdk.org
Mon Jun 30 23:53:39 UTC 2025


On Sun, 29 Jun 2025 20:23:53 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:

>> src/java.base/share/classes/java/nio/BufferCleaner.java line 243:
>> 
>>> 241:                 return;
>>> 242:             }
>>> 243:             cleaningThread = new CleaningThread();
>> 
>> I think double-checked locking could work well here.
>
> Sure, but why bother?

To reduce the thread-safety cost of every `register()` (after the first) down to a volatile read, instead of an `Object.lock()`.

But perhaps this isn't that hot a code path - depending on how frequently the app creates (and registers) buffers.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25289#discussion_r2176105290


More information about the nio-dev mailing list