< prev index next >

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

Print this page
@@ -1,7 +1,7 @@
  /*
-  * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
+  * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * This code is free software; you can redistribute it and/or modify it
   * under the terms of the GNU General Public License version 2 only, as
   * published by the Free Software Foundation.

@@ -36,10 +36,11 @@
  import java.util.concurrent.ExecutorService;
  import java.util.concurrent.Executors;
  import java.util.concurrent.ThreadFactory;
  import java.util.concurrent.locks.LockSupport;
  
+ import jdk.test.lib.thread.VThreadScheduler;
  import jdk.test.lib.thread.VThreadRunner;
  import org.junit.jupiter.api.Test;
  import static org.junit.jupiter.api.Assertions.*;
  import static org.junit.jupiter.api.Assumptions.*;
  

@@ -140,15 +141,14 @@
      /**
       * Test that invoking a static method does not pin the carrier thread.
       */
      @Test
      void testInvokeStatic6() throws Exception {
-         assumeTrue(ThreadBuilders.supportsCustomScheduler(), "No support for custom schedulers");
+         assumeTrue(VThreadScheduler.supportsCustomScheduler(), "No support for custom schedulers");
          Method parkMethod = Parker.class.getDeclaredMethod("park");
          try (ExecutorService scheduler = Executors.newFixedThreadPool(1)) {
-             Thread.Builder builder = ThreadBuilders.virtualThreadBuilder(scheduler);
-             ThreadFactory factory = builder.factory();
+             ThreadFactory factory = VThreadScheduler.virtualThreadFactory(scheduler);
  
              var ready = new CountDownLatch(1);
              Thread vthread = factory.newThread(() -> {
                  ready.countDown();
                  try {

@@ -319,15 +319,14 @@
      /**
       * Test that newInstance does not pin the carrier thread
       */
      @Test
      void testNewInstance6() throws Exception {
-         assumeTrue(ThreadBuilders.supportsCustomScheduler(), "No support for custom schedulers");
+         assumeTrue(VThreadScheduler.supportsCustomScheduler(), "No support for custom schedulers");
          Constructor<?> ctor = Parker.class.getDeclaredConstructor();
          try (ExecutorService scheduler = Executors.newFixedThreadPool(1)) {
-             Thread.Builder builder = ThreadBuilders.virtualThreadBuilder(scheduler);
-             ThreadFactory factory = builder.factory();
+             ThreadFactory factory = VThreadScheduler.virtualThreadFactory(scheduler);
  
              var ready = new CountDownLatch(1);
              Thread vthread = factory.newThread(() -> {
                  ready.countDown();
                  try {
< prev index next >