< prev index next >

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

Print this page
*** 298,14 ***
              assertContainsPinnedEvent(recording, vthread);
          }
      }
  
      /**
!      * Test jdk.VirtualThreadPinned event when waiting for a class initializer.
       */
      @Test
!     void testWaitingForClassInitializer() throws Exception {
          class TestClass {
              static {
                  LockSupport.park();
              }
              static void m() {
--- 298,14 ---
              assertContainsPinnedEvent(recording, vthread);
          }
      }
  
      /**
!      * Test jdk.VirtualThreadPinned event when waiting for a class initializer while pinned.
       */
      @Test
!     void testWaitingForClassInitializerWhenPinned() throws Exception {
          class TestClass {
              static {
                  LockSupport.park();
              }
              static void m() {

*** 324,11 ***
                  started1.set(true);
                  TestClass.m();
              });
              Thread vthread2 = Thread.ofVirtual().unstarted(() -> {
                  started2.set(true);
!                 TestClass.m();
              });
  
              try {
                  // start first virtual thread and wait for it to start + park
                  vthread1.start();
--- 324,13 ---
                  started1.set(true);
                  TestClass.m();
              });
              Thread vthread2 = Thread.ofVirtual().unstarted(() -> {
                  started2.set(true);
!                 VThreadPinner.runPinned(() -> {
+                     TestClass.m();
+                 });
              });
  
              try {
                  // start first virtual thread and wait for it to start + park
                  vthread1.start();

*** 337,11 ***
  
                  // start second virtual thread and wait for it to start
                  vthread2.start();
                  awaitTrue(started2);
  
!                 // give time for second virtual thread to wait on the MutexLocker
                  Thread.sleep(3000);
  
              } finally {
                  LockSupport.unpark(vthread1);
                  vthread1.join();
--- 339,11 ---
  
                  // start second virtual thread and wait for it to start
                  vthread2.start();
                  awaitTrue(started2);
  
!                 // give time for second virtual thread to wait in VM
                  Thread.sleep(3000);
  
              } finally {
                  LockSupport.unpark(vthread1);
                  vthread1.join();
< prev index next >