1 /* 2 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. 3 * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. 4 */ 5 6 import java.io.File; 7 import java.nio.file.Paths; 8 import java.time.Duration; 9 10 import jdk.test.lib.process.ProcessTools; 11 import jdk.test.lib.process.OutputAnalyzer; 12 13 /* 14 * @test 15 * @requires vm.debug 16 * @library /test/lib 17 * @run main/native TestTrans 18 */ 19 public class TestTrans { 20 21 public static native void someTime(int ms); 22 23 public static void main(String[] args) throws Exception { 24 String lib = System.getProperty("test.nativepath"); 25 ProcessBuilder pb = 26 ProcessTools.createJavaProcessBuilder( 27 true, 28 "-Djava.library.path=" + lib, 29 "-XX:+SafepointALot", 30 "-XX:GuaranteedSafepointInterval=20", 31 "-Xlog:ergo*", 32 "-XX:ParallelGCThreads=1", 33 "-XX:ConcGCThreads=1", 34 "-XX:CICompilerCount=2", 35 "TestTrans$Test"); 36 37 38 OutputAnalyzer output = ProcessTools.executeProcess(pb); 39 output.reportDiagnosticSummary(); 40 output.shouldHaveExitValue(0); 41 output.stdoutShouldContain("JOINED"); 42 } 43 44 static class Test implements Runnable { 45 final static int testLoops = 2000; 46 final static int testSleep = 1; //ms 47 48 public static void main(String[] args) throws Exception { 49 System.loadLibrary("TestTrans"); 50 Test test = new Test(); 51 Thread[] threads = new Thread[64]; 52 for (int i = 0; i<threads.length ; i++) { 53 threads[i] = new Thread(test); 54 threads[i].start(); 55 } 56 for (Thread t : threads) { 57 t.join(); 58 } 59 System.out.println("JOINED"); 60 } 61 62 @Override 63 public void run() { 64 for (int i = 0; i<testLoops ; i++) { 65 someTime(testSleep); 66 } 67 } 68 } 69 }