On Wed, 5 Oct 2022 19:02:04 GMT, Chris Plummer <[email protected]> wrote:
>> This is a test only change for two tests for virtual threads that
>> hang/timeout on single core systems. The two tests involve pinning and
>> require at least two carrier threads. The test lib used by these tests is
>> updated to define a new method that ensures parallelism is at least a given
>> value and both tests are updated to use this. There are a number of tests in
>> the debugger area that may potentially use this in the future.
>
> 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.
> 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.
> 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.
-------------
PR: https://git.openjdk.org/jdk/pull/10562