RFR: 8291429: java/lang/Thread/virtual/ThreadAPI.java timed out on single core system

Chris Plummer cjplummer at openjdk.org
Wed Oct 5 19:50:12 UTC 2022


On Wed, 5 Oct 2022 19:30:46 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> test/jdk/java/lang/management/ThreadMXBean/VirtualThreadDeadlocks.java line 30:
>> 
>>> 28:  *   platform and virtual threads in deadlock
>>> 29:  * @enablePreview
>>> 30:  * @modules java.base/java.lang:+open java.management
>> 
>> Can you explain the need for this change?
>
> That is jtreg foo to open java.lang, needed to access a private field.

ok

>> test/jdk/java/lang/management/ThreadMXBean/VirtualThreadDeadlocks.java line 68:
>> 
>>> 66:     public static void main(String[] args) throws Exception {
>>> 67:         // need at least two carrier threads due to pinning
>>> 68:         VThreadRunner.ensureParallelism(2);
>> 
>> In this test case why is there no need to maintain a reference to the returned AutoCloseable? Isn't there a chance it can be collected and the old parallelism value restored while the test is running.
>
> This test doesn't need to restore it so it doesn't keep a reference and not an issue if it is GC'ed.

It's not a matter of whether or not the test needs to restore it. It _will_ restore it if there is a GC, and if this happens before the test completes, it could find itself without enough carrier threads.

>> test/lib/jdk/test/lib/thread/VThreadRunner.java line 176:
>> 
>>> 174:                     if (!closed) {
>>> 175:                         closed = true;
>>> 176:                         pool.setParallelism(parallelism);
>> 
>> What is the rationale for restoring the parallelism? It's just a test. Is this really necessary? Are we reusing the JVM to run other tests, and even if we are does it matter?
>
> Look at the ThreadAPI test as an example. It's a TestNG with dozens of test methods. All but one can run on single core systems.

Ok.

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

PR: https://git.openjdk.org/jdk/pull/10562


More information about the serviceability-dev mailing list