RFR: 8302899: Executors.newSingleThreadExecutor can use Cleaner to shutdown executor [v3]
Brent Christian
bchristi at openjdk.org
Wed Feb 22 18:43:43 UTC 2023
On Wed, 22 Feb 2023 18:02:46 GMT, Alan Bateman <alanb at openjdk.org> wrote:
>> src/java.base/share/classes/java/util/concurrent/Executors.java line 844:
>>
>>> 842: @Override
>>> 843: public void shutdown() {
>>> 844: cleaner.clean();
>>
>> Hmmm... so now shutdown no longer requires permission. You should probably call super.shutdown() before invoking cleaner.clean(), assuming that shutdown() can be called twice. You could modify the cleanup action to only call shutdown() if isShutdown() returns false.
>
>> Hmmm... so now shutdown no longer requires permission. You should probably call super.shutdown() before invoking cleaner.clean(), assuming that shutdown() can be called twice. You could modify the cleanup action to only call shutdown() if isShutdown() returns false.
>
> You are right. It will be a non-issue once the SM goes away but while that execution mode is supported then the shutdown method and the cleaner action have to be different (as it was initially).
The cleaning action would not have access to the isShutdown() instance method of the (Phantom-reachable) AutoShutdownDelegatedExecutorService.
-------------
PR: https://git.openjdk.org/jdk/pull/12675
More information about the core-libs-dev
mailing list