18 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
19 * or visit www.oracle.com if you need additional information or have any
20 * questions.
21 */
22
23 /*
24 * This file is available under and governed by the GNU General Public
25 * License version 2 only, as published by the Free Software Foundation.
26 * However, the following notice accompanied the original version of this
27 * file:
28 *
29 * Written by Doug Lea with assistance from members of JCP JSR-166
30 * Expert Group and released to the public domain, as explained at
31 * http://creativecommons.org/publicdomain/zero/1.0/
32 */
33
34 /*
35 * @test
36 * @bug 4486658
37 * @summary basic safety and liveness of ReentrantLocks, and other locks based on them
38 * @library /lib/testlibrary/
39 */
40
41 import static java.util.concurrent.TimeUnit.MILLISECONDS;
42
43 import java.util.concurrent.CyclicBarrier;
44 import java.util.concurrent.ExecutorService;
45 import java.util.concurrent.Executors;
46 import java.util.concurrent.Semaphore;
47 import java.util.concurrent.ThreadLocalRandom;
48 import java.util.concurrent.locks.Lock;
49 import java.util.concurrent.locks.ReentrantLock;
50 import java.util.concurrent.locks.ReentrantReadWriteLock;
51 import jdk.testlibrary.Utils;
52
53 public final class CheckedLockLoops {
54 static final long LONG_DELAY_MS = Utils.adjustTimeout(10_000);
55 static ExecutorService pool;
56
57 public static void main(String[] args) throws Exception {
58 final int maxThreads = (args.length > 0)
59 ? Integer.parseInt(args[0])
60 : 5;
61 int iters = 3000;
62
63 pool = Executors.newCachedThreadPool();
64 for (int i = 1; i <= maxThreads; i += (i+1) >>> 1) {
65 oneTest(i, iters / i);
66 }
67 pool.shutdown();
68 if (! pool.awaitTermination(LONG_DELAY_MS, MILLISECONDS))
69 throw new Error();
70 pool = null;
71 }
|
18 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
19 * or visit www.oracle.com if you need additional information or have any
20 * questions.
21 */
22
23 /*
24 * This file is available under and governed by the GNU General Public
25 * License version 2 only, as published by the Free Software Foundation.
26 * However, the following notice accompanied the original version of this
27 * file:
28 *
29 * Written by Doug Lea with assistance from members of JCP JSR-166
30 * Expert Group and released to the public domain, as explained at
31 * http://creativecommons.org/publicdomain/zero/1.0/
32 */
33
34 /*
35 * @test
36 * @bug 4486658
37 * @summary basic safety and liveness of ReentrantLocks, and other locks based on them
38 * @library /test/lib
39 */
40
41 import static java.util.concurrent.TimeUnit.MILLISECONDS;
42
43 import java.util.concurrent.CyclicBarrier;
44 import java.util.concurrent.ExecutorService;
45 import java.util.concurrent.Executors;
46 import java.util.concurrent.Semaphore;
47 import java.util.concurrent.ThreadLocalRandom;
48 import java.util.concurrent.locks.Lock;
49 import java.util.concurrent.locks.ReentrantLock;
50 import java.util.concurrent.locks.ReentrantReadWriteLock;
51 import jdk.test.lib.Utils;
52
53 public final class CheckedLockLoops {
54 static final long LONG_DELAY_MS = Utils.adjustTimeout(10_000);
55 static ExecutorService pool;
56
57 public static void main(String[] args) throws Exception {
58 final int maxThreads = (args.length > 0)
59 ? Integer.parseInt(args[0])
60 : 5;
61 int iters = 3000;
62
63 pool = Executors.newCachedThreadPool();
64 for (int i = 1; i <= maxThreads; i += (i+1) >>> 1) {
65 oneTest(i, iters / i);
66 }
67 pool.shutdown();
68 if (! pool.awaitTermination(LONG_DELAY_MS, MILLISECONDS))
69 throw new Error();
70 pool = null;
71 }
|