2362N/A * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * Sample target application for jvmti demos 0N/A * java Context [threadCount [iterationCount [sleepContention]]] 0N/A * Default: java Context 5 10 0 0N/A * threadCount Number of threads 0N/A * iterationCount Total turns taken for all threads 0N/A * sleepContention Time for main thread to sleep while holding lock 0N/A * (creates monitor contention on all other threads) 0N/A/* Used to sync up turns and keep track of who's turn it is */ 0N/A/* Creates a bunch of threads that sequentially take turns */ 0N/A /* Used to track threads */ 0N/A /* Used for each Context thread */ 0N/A /* Override defaults */ 0N/A /* Get all threads running (they will block until we set turn) */ 0N/A /* Sleep to make sure thread_index 0 make it to the wait call */ 0N/A /* Save start time */ 0N/A /* This triggers the starting of taking turns */ 0N/A /* Wait for threads to finish (after everyone has had their turns) */ 0N/A /* Create some monitor contention by sleeping with lock */ 0N/A /* Thread object to run */ 0N/A /* Main for thread */ 0N/A /* Loop until we make sure we get all our turns */ 0N/A /* Keep waiting for our turn */ 0N/A /* MY TURN! Each thread gets thread_turns */ 0N/A +
" turns taken by this thread");
0N/A /* Give next thread a turn */ 0N/A /* If we've had all our turns, break out of this loop */ 0N/A /* Make sure we got all our turns */