< prev index next >

test/hotspot/jtreg/serviceability/jvmti/GetOwnedMonitorInfo/GetOwnedMonitorInfoTest.java

Print this page
@@ -25,12 +25,12 @@
  /**
   * @test
   * @bug 8185164
   * @summary Checks that a contended monitor does not show up in the list of owned monitors
   * @requires vm.jvmti
-  * @compile GetOwnedMonitorInfoTest.java
-  * @run main/othervm/native -agentlib:GetOwnedMonitorInfoTest GetOwnedMonitorInfoTest
+  * @compile --enable-preview -source ${jdk.version} GetOwnedMonitorInfoTest.java
+  * @run main/othervm/native --enable-preview -agentlib:GetOwnedMonitorInfoTest GetOwnedMonitorInfoTest
   */
  
  import java.io.PrintStream;
  
  public class GetOwnedMonitorInfoTest {

@@ -48,13 +48,19 @@
  
      private static native int check();
      private static native boolean hasEventPosted();
  
      public static void main(String[] args) throws Exception {
+         runTest(true);
+         runTest(false);
+     }
+ 
+     public static void runTest(boolean isVirtual) throws Exception {
+         var threadFactory = isVirtual ? Thread.ofVirtual().factory() : Thread.ofPlatform().factory();
          final GetOwnedMonitorInfoTest lock = new GetOwnedMonitorInfoTest();
  
-         Thread t1 = new Thread(() -> {
+         Thread t1 = threadFactory.newThread(() -> {
              synchronized (lock) {
                  System.out.println("Thread in sync section: "
                                     + Thread.currentThread().getName());
              }
          });
< prev index next >