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 Martin Buchholz and Doug Lea with assistance from
30 * members of JCP JSR-166 Expert Group and released to the public
31 * domain, as explained at
32 * http://creativecommons.org/publicdomain/zero/1.0/
33 */
34
35 /*
36 * @test
37 * @summary Should be able to shutdown a pool when worker creation failed.
38 * @library /lib/testlibrary/
39 */
40
41 import static java.util.concurrent.TimeUnit.MILLISECONDS;
42
43 import java.util.concurrent.LinkedBlockingQueue;
44 import java.util.concurrent.ThreadFactory;
45 import java.util.concurrent.ThreadPoolExecutor;
46 import java.util.concurrent.TimeUnit;
47 import jdk.testlibrary.Utils;
48
49 public class FlakyThreadFactory {
50 static final long LONG_DELAY_MS = Utils.adjustTimeout(10_000);
51
52 void test(String[] args) throws Throwable {
53 test(NullPointerException.class,
54 new ThreadFactory() {
55 public Thread newThread(Runnable r) {
56 throw new NullPointerException();
57 }});
58 test(OutOfMemoryError.class,
59 new ThreadFactory() {
60 @SuppressWarnings("DeadThread")
61 public Thread newThread(Runnable r) {
62 // We expect this to throw OOME, but ...
63 new Thread(null, r, "a natural OOME", 1L << 60);
64 // """On some platforms, the value of the stackSize
65 // parameter may have no effect whatsoever."""
66 throw new OutOfMemoryError("artificial OOME");
67 }});
|
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 Martin Buchholz and Doug Lea with assistance from
30 * members of JCP JSR-166 Expert Group and released to the public
31 * domain, as explained at
32 * http://creativecommons.org/publicdomain/zero/1.0/
33 */
34
35 /*
36 * @test
37 * @summary Should be able to shutdown a pool when worker creation failed.
38 * @library /test/lib
39 */
40
41 import static java.util.concurrent.TimeUnit.MILLISECONDS;
42
43 import java.util.concurrent.LinkedBlockingQueue;
44 import java.util.concurrent.ThreadFactory;
45 import java.util.concurrent.ThreadPoolExecutor;
46 import java.util.concurrent.TimeUnit;
47 import jdk.test.lib.Utils;
48
49 public class FlakyThreadFactory {
50 static final long LONG_DELAY_MS = Utils.adjustTimeout(10_000);
51
52 void test(String[] args) throws Throwable {
53 test(NullPointerException.class,
54 new ThreadFactory() {
55 public Thread newThread(Runnable r) {
56 throw new NullPointerException();
57 }});
58 test(OutOfMemoryError.class,
59 new ThreadFactory() {
60 @SuppressWarnings("DeadThread")
61 public Thread newThread(Runnable r) {
62 // We expect this to throw OOME, but ...
63 new Thread(null, r, "a natural OOME", 1L << 60);
64 // """On some platforms, the value of the stackSize
65 // parameter may have no effect whatsoever."""
66 throw new OutOfMemoryError("artificial OOME");
67 }});
|