RFR: 8286294 : ForkJoinPool.commonPool().close() spins [v4]

Doug Lea dl at openjdk.java.net
Sun May 8 12:00:39 UTC 2022


On Sun, 8 May 2022 01:51:17 GMT, Martin Buchholz <martin at openjdk.org> wrote:

>> Doug Lea has updated the pull request incrementally with three additional commits since the last revision:
>> 
>>  - Accommodate restrictive SecurityManagers
>>  - merge with loom updates
>>    Merge remote-tracking branch 'refs/remotes/origin/JDK-8286294' into JDK-8286294
>>  - Fix testLazySubmit; enable suite
>
> Here's a suggested strengthening of testCloseCommonPool:
> 
> - close should have "no effect", not just "not terminate".
> - the submitted task will be run by the pool ... eventually  (which suggests that closing the common pool maybe should quiesce the pool before returning)
> -  I might merge this with testCommonPoolShutDown
> 
>     /**
>      * Implicitly closing common pool using try-with-resources has no effect.
>      */
>     public void testCloseCommonPool() {
>         ForkJoinTask f = new FibAction(8);
>         ForkJoinPool pool;
>         try (ForkJoinPool p = pool = ForkJoinPool.commonPool()) {
>             p.execute(f);
>         }
> 
>         assertFalse(pool.isShutdown());
>         assertFalse(pool.isTerminating());
>         assertFalse(pool.isTerminated());
> 
>         String prop = System.getProperty(
>             "java.util.concurrent.ForkJoinPool.common.parallelism");
>         if (! "0".equals(prop)) {
>             f.join();
>             checkCompletedNormally(f);
>         }
>     }

@Martin-Buchholz thanks for test improvements. I'm leaving further FJP tweaks for some other time to avoid possibility of problems after already merging with loom commit

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

PR: https://git.openjdk.java.net/jdk/pull/8577


More information about the core-libs-dev mailing list