A number of the tests added to test virtual threads in JDK 19 have long execution times.
vthread/BlockingChannelOps and vthread/BlockingSocketOps take the longest time as they run a lot tests and need to run in several configurations. This is tracked by JDK-8294375.
This issue tracks improvements to:
jdk/jdk/incubator/concurrent/StructuredTaskScope/StructuredTaskScopeTest.java
jdk/jdk/internal/misc/ThreadFlock/ThreadFlockTest.java
jdk/java/util/concurrent/ThreadPerTaskExecutor/ThreadPerTaskExecutorTest.java
jdk/java/util/concurrent/ExecutorService/CloseTest.java
jdk/java/lang/Thread/virtual/ThreadAPI.java
and the stress/reliability tests in jdk/java/lang/Thread/virtual/stress.
StructuredTaskScopeTest, ThreadFlockTest and ThreadPerTaskExecutorTest run a lot of tests with thread factories for both platform and virtual threads. These can be split into two runs, and some of the delays used by some of their tests can be reduced without impacting the reliability of the tests.
CloseTest has sleeps that mostly not needed.
ThreadAPI has several sleeps to improve the chances that a virtual thread is parked/blocked. These sleeps can be replaced with code that polls the thread state. In addition, testing the duration of Thread.sleep can be reduced to two cases. These could run concurrently but it would make the test harder to debug in the event of a test failure.
The stress tests in jdk/java/lang/Thread/virtual/stress are proving very useful to catch issues in both hotspot and library code. Most have an iteration count and some can be dialled down for release builds. This issue does not propose to change the iteration count for debug builds at this time.