6968933: Clip loop() deadlock in DirectAudioDevice$DirectClip.run
authorkevinw
Tue, 21 Dec 2010 11:32:34 +0000
changeset 7805 ca2d2a7e657a
parent 7804 c59149ba3780
child 7806 ad4062c4253d
6968933: Clip loop() deadlock in DirectAudioDevice$DirectClip.run Reviewed-by: amenkov
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) {}