# HG changeset patch # User kevinw # Date 1292931154 0 # Node ID ca2d2a7e657aca71a6fc3ef768e2c07422be805f # Parent c59149ba3780896099e8305d3baec990f7b185e0 6968933: Clip loop() deadlock in DirectAudioDevice$DirectClip.run Reviewed-by: amenkov diff -r c59149ba3780 -r ca2d2a7e657a jdk/src/share/classes/com/sun/media/sound/DirectAudioDevice.java --- a/jdk/src/share/classes/com/sun/media/sound/DirectAudioDevice.java Tue Dec 21 17:35:47 2010 +0800 +++ b/jdk/src/share/classes/com/sun/media/sound/DirectAudioDevice.java Tue Dec 21 11:32:34 2010 +0000 @@ -1393,8 +1393,11 @@ public void run() { if (Printer.trace) Printer.trace(">>> DirectClip: run() threadID="+Thread.currentThread().getId()); while (thread != null) { - if (!doIO) { - synchronized(lock) { + // doIO is volatile, but we could check it, then get + // pre-empted while another thread changes doIO and notifies, + // before we wait (so we sleep in wait forever). + synchronized(lock) { + if (!doIO) { try { lock.wait(); } catch(InterruptedException ie) {}