< prev index next >

test/jdk/java/lang/Thread/virtual/stress/GetStackTraceALotWhenPinned.java

Print this page
*** 26,19 ***
   * @bug 8322818
   * @summary Stress test Thread.getStackTrace on a virtual thread that is pinned
   * @requires vm.debug != true
   * @modules java.base/java.lang:+open
   * @library /test/lib
!  * @run main/othervm GetStackTraceALotWhenPinned 500000
   */
  
  /*
   * @test
   * @requires vm.debug == true
   * @modules java.base/java.lang:+open
   * @library /test/lib
!  * @run main/othervm/timeout=300 GetStackTraceALotWhenPinned 200000
   */
  
  import java.time.Instant;
  import java.util.concurrent.atomic.AtomicInteger;
  import java.util.concurrent.locks.LockSupport;
--- 26,19 ---
   * @bug 8322818
   * @summary Stress test Thread.getStackTrace on a virtual thread that is pinned
   * @requires vm.debug != true
   * @modules java.base/java.lang:+open
   * @library /test/lib
!  * @run main/othervm --enable-native-access=ALL-UNNAMED GetStackTraceALotWhenPinned 500000
   */
  
  /*
   * @test
   * @requires vm.debug == true
   * @modules java.base/java.lang:+open
   * @library /test/lib
!  * @run main/othervm/timeout=300 --enable-native-access=ALL-UNNAMED GetStackTraceALotWhenPinned 200000
   */
  
  import java.time.Instant;
  import java.util.concurrent.atomic.AtomicInteger;
  import java.util.concurrent.locks.LockSupport;

*** 77,20 ***
                  timed = !timed;
              }
          });
  
          long lastTimestamp = System.currentTimeMillis();
!         for (int i = 0; i < iterations; i++) {
              // wait for virtual thread to arrive
              barrier.await();
  
              thread.getStackTrace();
              LockSupport.unpark(thread);
  
              long currentTime = System.currentTimeMillis();
!             if ((currentTime - lastTimestamp) > 500) {
!                 System.out.format("%s %d remaining ...%n", Instant.now(), (iterations - i));
                  lastTimestamp = currentTime;
              }
          }
      }
  
--- 77,20 ---
                  timed = !timed;
              }
          });
  
          long lastTimestamp = System.currentTimeMillis();
!         for (int i = 1; i <= iterations; i++) {
              // wait for virtual thread to arrive
              barrier.await();
  
              thread.getStackTrace();
              LockSupport.unpark(thread);
  
              long currentTime = System.currentTimeMillis();
!             if (i == iterations || ((currentTime - lastTimestamp) > 500)) {
!                 System.out.format("%s => %d of %d%n", Instant.now(), i, iterations);
                  lastTimestamp = currentTime;
              }
          }
      }
  
< prev index next >