On Sun, 29 Jun 2025 20:23:53 GMT, Kim Barrett <kbarr...@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

Reply via email to