< prev index next >

test/jdk/java/lang/Thread/virtual/ParkWithFixedThreadPool.java

Print this page
*** 24,16 ***
--- 24,18 ---
  /*
   * @test
   * @summary Test virtual thread park when scheduler is a fixed thread pool
   * @requires vm.continuations
   * @modules java.base/java.lang:+open
+  * @library /test/lib
   * @run main ParkWithFixedThreadPool
   */
  
  import java.util.concurrent.*;
  import java.util.concurrent.atomic.*;
  import java.util.concurrent.locks.LockSupport;
+ import jdk.test.lib.thread.VThreadScheduler;
  
  public class ParkWithFixedThreadPool {
      public static void main(String[] args) throws Exception {
          try (ExecutorService scheduler = Executors.newFixedThreadPool(8)) {
              int vthreadCount = 300;

*** 56,13 ***
                          LockSupport.park();
                      }
                  }
              };
  
!             ThreadFactory factory = ThreadBuilders.virtualThreadBuilder(scheduler)
-                     .name("vthread-", 0)
-                     .factory();
  
              for (int i = 0; i < vthreadCount; i++) {
                  vthreads[i] = factory.newThread(target);
              }
              for (int i = 0; i < vthreadCount; i++) {
--- 58,11 ---
                          LockSupport.park();
                      }
                  }
              };
  
!             ThreadFactory factory = VThreadScheduler.virtualThreadFactory(scheduler);
  
              for (int i = 0; i < vthreadCount; i++) {
                  vthreads[i] = factory.newThread(target);
              }
              for (int i = 0; i < vthreadCount; i++) {
< prev index next >