RFR: 8302899: Executors.newSingleThreadExecutor can use Cleaner to shutdown executor [v2]
Martin Buchholz
martin at openjdk.org
Tue Feb 21 20:30:29 UTC 2023
On Tue, 21 Feb 2023 16:36:26 GMT, Alan Bateman <alanb at openjdk.org> wrote:
>> test/jdk/java/util/concurrent/Executors/AutoShutdown.java line 133:
>>
>>> 131: while (!terminated) {
>>> 132: System.gc();
>>> 133: terminated = executor.awaitTermination(100, TimeUnit.MILLISECONDS);
>>
>> @AlanBateman Perhaps worth having some upper limit as to how long it will wait until failing the test?
>
> jtreg will look after this. The default timeout is 120s but it can be adjusted with a timeout factor (make time uses a timeout factor of 4). So it would be possible to put a limit on this in the test but it can be problematic, e.g. with debug builds + Xcomp for example.
I have written such code many times, and I've always had success with a (jtreg-scaled) 10 second timeout. E.g.
static final long LONG_DELAY_MS = Utils.adjustTimeout(10_000);
(But that's before I became aware of existence of (slow) Raspberry Pis.)
I continue to feel guilty about never having written a proper gc awaiting library utility for openjdk, like I did for guava here:
https://github.com/google/guava/blob/master/guava-testlib/src/com/google/common/testing/GcFinalization.java
-------------
PR: https://git.openjdk.org/jdk/pull/12675
More information about the core-libs-dev
mailing list