/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 5093922 2120055
* @summary Test that NotificationBroadcasterSupport can be subclassed
* and used with synchronized(this) without causing deadlock
* @author Eamonn McManus
* @run clean BroadcasterSupportDeadlockTest
* @run build BroadcasterSupportDeadlockTest
* @run main BroadcasterSupportDeadlockTest
*/
import javax.management.*;
public class BroadcasterSupportDeadlockTest {
try {
} catch (Throwable t) {
return;
}
// Thread 1 - block the Broadcaster
public void run() {
try {
} catch (Exception e) {
} finally {
}
}
};
/* Wait for Thread 1 to be doing Object.wait(). It's very
difficult to synchronize properly here so we wait for the
semaphore, then wait a little longer for the mbs.invoke to
run, then just in case that isn't enough, we wait for the
thread to be in WAITING state. This isn't foolproof,
because the machine could be very slow and the
Thread.getState() could find the thread in WAITING state
due to some operation it does on its way to the one we're
interested in. */
// Thread 2 - try to add a listener
};
public void run() {
try {
} catch (Exception e) {
}
}
};
/* Wait for Thread 2 to be blocked on the monitor or to
succeed. */
for (int i = 0; i < 1000/*ms*/; i++) {
case TERMINATED:
return;
case BLOCKED:
break;
default:
break;
}
}
}
StackTraceElement[] stack) {
else {
}
}
public static interface BroadcasterMBean {
}
public static class Broadcaster
extends NotificationBroadcasterSupport
implements BroadcasterMBean {
synchronized (lock) {
try {
// Let the caller know that it can now wait for us to
// hit the WAITING state
} catch (InterruptedException e) {
}
}
}
}
}