86
87 // Wait for the invocation thread to complete.
88 thread.join(LONG_DELAY_MS);
89 if (thread.isAlive()) {
90 thread.interrupt();
91 thread.join(LONG_DELAY_MS);
92 throw new Error(
93 String.format("invokeAll timed out after %d ms",
94 LONG_DELAY_MS));
95 }
96 }
97
98 /**
99 * A helper class with a method to wait for a notification.
100 *
101 * The notification is received via the
102 * {@code sendNotification} method.
103 */
104 static class NotificationReceiver {
105 /** Has the notifiee been notified? */
106 boolean notified = false;
107
108 /**
109 * Notify the notification receiver.
110 */
111 public synchronized void sendNotification() {
112 notified = true;
113 notifyAll();
114 }
115
116 /**
117 * Waits until a notification has been received.
118 *
119 * @throws InterruptedException if the wait is interrupted
120 */
121 public synchronized void waitForNotification()
122 throws InterruptedException {
123 while (! notified)
124 wait();
125 }
126 }
|
86
87 // Wait for the invocation thread to complete.
88 thread.join(LONG_DELAY_MS);
89 if (thread.isAlive()) {
90 thread.interrupt();
91 thread.join(LONG_DELAY_MS);
92 throw new Error(
93 String.format("invokeAll timed out after %d ms",
94 LONG_DELAY_MS));
95 }
96 }
97
98 /**
99 * A helper class with a method to wait for a notification.
100 *
101 * The notification is received via the
102 * {@code sendNotification} method.
103 */
104 static class NotificationReceiver {
105 /** Has the notifiee been notified? */
106 boolean notified;
107
108 /**
109 * Notify the notification receiver.
110 */
111 public synchronized void sendNotification() {
112 notified = true;
113 notifyAll();
114 }
115
116 /**
117 * Waits until a notification has been received.
118 *
119 * @throws InterruptedException if the wait is interrupted
120 */
121 public synchronized void waitForNotification()
122 throws InterruptedException {
123 while (! notified)
124 wait();
125 }
126 }
|