@@ -373,7 +373,7 @@ public synchronized void waitUntilCount(long count) {
373
373
374
374
@ Test
375
375
public void testPauseManyThreads () throws ExecutionException , InterruptedException , IOException {
376
- int nThreads = Runtime .getRuntime ().availableProcessors () + 2 ;
376
+ int nThreads = Runtime .getRuntime ().availableProcessors () + 1 ;
377
377
ExecutorService executorService = threadPool (nThreads , vthreads );
378
378
ByteArrayOutputStream outputStream = new ByteArrayOutputStream ();
379
379
Engine .Builder engineBuilder = Engine .newBuilder ().allowExperimentalOptions (true ).option ("engine.SynchronousThreadLocalActionMaxWait" , "1" ).out (outputStream ).err (outputStream );
@@ -462,7 +462,7 @@ public void onReturnExceptional(EventContext c, VirtualFrame frame, Throwable ex
462
462
Assert .assertFalse (pauseFuture1 .isCancelled ());
463
463
// The one thread executing context1 is now paused
464
464
/*
465
- * Execute the same code in context2 in availableProcessors + 1 (nThreads - 1) threads.
465
+ * Execute the same code in context2 in availableProcessors (nThreads - 1) threads.
466
466
*/
467
467
for (int i = 1 ; i < nThreads ; i ++) {
468
468
executorService .submit (() -> {
@@ -484,13 +484,13 @@ public void onReturnExceptional(EventContext c, VirtualFrame frame, Throwable ex
484
484
* the synchronous pause thread local action may not reach the synchronization point in
485
485
* case virtual threads are used and is automatically cancelled. The reason for not
486
486
* reaching the synchronization point is that when availableProcessors of these threads
487
- * are pinned and then the waiting for the start sync of the pause thread local action
488
- * using LockSupport.parkNanos, the (availableProcessors + 1)-th thread cannot run
489
- * because the parallelism of the default virtual thread scheduler is only
490
- * availableProcessors and none of the "parked" threads, though waiting, can be
491
- * compensated for due to the pinning. Also, the timeout for the pause thread local
492
- * action sync is pretty small (one second) so the cancellation might occur even for
493
- * platform threads in case some unusual slowdown.
487
+ * are pinned and waiting for the start sync of the pause thread local action using
488
+ * LockSupport.parkNanos (or already paused in case of the already paused context1
489
+ * thread), the (availableProcessors + 1)-th thread cannot run because the parallelism
490
+ * of the default virtual thread scheduler is only availableProcessors and none of the
491
+ * "parked" threads, though waiting, can be compensated for due to the pinning. Also,
492
+ * the timeout for the pause thread local action sync is pretty small (one second) so
493
+ * the cancellation might occur even for platform threads in case some unusual slowdown.
494
494
*/
495
495
boolean pause2Cancelled = pauseFuture2 .isCancelled ();
496
496
// If context2 pausing is cancelled, new thread in context2 should not be paused even
0 commit comments