[concurrency-interest] DirectByteBuffers and reachabilityFence

Justin Sampson jsampson at guidewire.com
Tue Dec 15 15:19:44 EST 2015


David Holmes wrote:

> Here's another nasty little reachability/finalize example:
>
> https://bugs.openjdk.java.net/browse/JDK-8145304

Interesting! The use case is a bit odd -- I mean, why bother with an
executor when it's not going to be used for anything but a single
task? -- but as a general design issue, is this an example of the
kind of thing that should never have been using finalization in the
first place? I.e., we all know that finalization is problematic, but
it seems like it's occasionally useful for managing native resources
if done carefully. This is just a thread pool. If the programmer
never explicitly shuts down the thread pool, shouldn't it just be
left running? It's their own fault, after all, for not using the API
properly, and the result of not shutting down during finalization is
merely a performance issue, not a correctness issue.

Cheers,
Justin



More information about the Concurrency-interest mailing list