01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: package org.apache.harmony.drlvm.tests.regression.h3582;
19:
20: import junit.framework.*;
21:
22: public class Test extends TestCase {
23: public static void main(String[] args) {
24: (new Test()).test();
25: }
26:
27: public void test() {
28: try {
29: (new MegaJoin()).test();
30: } catch (Throwable e) {
31: e.printStackTrace();
32: fail();
33: }
34: }
35: }
36:
37: class MegaJoin implements Runnable {
38: static int number_of_bosses = 10;
39: static int worker_threads_per_boss = 1000;
40: static int number_of_workers_created = 0;
41:
42: public static void main(String[] args) {
43: (new Test()).test();
44: }
45:
46: public void test() throws InterruptedException {
47: Thread[] boss_threads = new Thread[number_of_bosses];
48: int ii = 0;
49: for (ii = 0; ii < boss_threads.length; ii++) {
50: boss_threads[ii] = new Thread(new MegaJoin());
51: System.out.println("H3582: " + boss_threads[ii]);
52: boss_threads[ii].start();
53: }
54:
55: for (ii = 0; ii < boss_threads.length; ii++) {
56: try {
57: boss_threads[ii].join();
58: System.out.println("H3582: " + boss_threads[ii]
59: + " - finished!");
60: } catch (InterruptedException e) {
61: throw e;
62: }
63: }
64: System.out.println("H3582: PASSED!");
65: }
66:
67: public void run() {
68: Thread[] wta = new Thread[worker_threads_per_boss];
69: for (int ii = 0; ii < wta.length; ii++) {
70: wta[ii] = new Thread() {
71: public void run() {
72: //intentionally empty, only testing thread join
73: }
74: };
75: wta[ii].start();
76: }
77:
78: for (int ii = 0; ii < wta.length; ii++) {
79: try {
80: wta[ii].join();
81: } catch (InterruptedException e) {
82: System.out.println("Working thread exeption:");
83: e.printStackTrace();
84: }
85: }
86: }
87: }
|