< prev index next >

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

Print this page

 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  */
 23 
 24 /*
 25  * @test
 26  * @bug 8322818
 27  * @summary Stress test Thread.getStackTrace on a virtual thread that is pinned
 28  * @requires vm.debug != true
 29  * @modules java.base/java.lang:+open
 30  * @library /test/lib
 31  * @run main/othervm GetStackTraceALotWhenPinned 500000
 32  */
 33 
 34 /*
 35  * @test
 36  * @requires vm.debug == true
 37  * @modules java.base/java.lang:+open
 38  * @library /test/lib
 39  * @run main/othervm/timeout=300 GetStackTraceALotWhenPinned 200000
 40  */
 41 
 42 import java.time.Instant;
 43 import java.util.concurrent.atomic.AtomicInteger;
 44 import java.util.concurrent.locks.LockSupport;
 45 import jdk.test.lib.thread.VThreadRunner;
 46 import jdk.test.lib.thread.VThreadPinner;
 47 
 48 public class GetStackTraceALotWhenPinned {
 49 
 50     public static void main(String[] args) throws Exception {
 51         // need at least two carrier threads when main thread is a virtual thread
 52         if (Thread.currentThread().isVirtual()) {
 53             VThreadRunner.ensureParallelism(2);
 54         }
 55 
 56         int iterations = Integer.parseInt(args[0]);
 57         var barrier = new Barrier(2);
 58 
 59         // Start a virtual thread that loops doing Thread.yield and parking while pinned.

 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  */
 23 
 24 /*
 25  * @test
 26  * @bug 8322818
 27  * @summary Stress test Thread.getStackTrace on a virtual thread that is pinned
 28  * @requires vm.debug != true
 29  * @modules java.base/java.lang:+open
 30  * @library /test/lib
 31  * @run main/othervm --enable-native-access=ALL-UNNAMED GetStackTraceALotWhenPinned 500000
 32  */
 33 
 34 /*
 35  * @test
 36  * @requires vm.debug == true
 37  * @modules java.base/java.lang:+open
 38  * @library /test/lib
 39  * @run main/othervm/timeout=300 --enable-native-access=ALL-UNNAMED GetStackTraceALotWhenPinned 200000
 40  */
 41 
 42 import java.time.Instant;
 43 import java.util.concurrent.atomic.AtomicInteger;
 44 import java.util.concurrent.locks.LockSupport;
 45 import jdk.test.lib.thread.VThreadRunner;
 46 import jdk.test.lib.thread.VThreadPinner;
 47 
 48 public class GetStackTraceALotWhenPinned {
 49 
 50     public static void main(String[] args) throws Exception {
 51         // need at least two carrier threads when main thread is a virtual thread
 52         if (Thread.currentThread().isVirtual()) {
 53             VThreadRunner.ensureParallelism(2);
 54         }
 55 
 56         int iterations = Integer.parseInt(args[0]);
 57         var barrier = new Barrier(2);
 58 
 59         // Start a virtual thread that loops doing Thread.yield and parking while pinned.
< prev index next >