[libbluray-devel] Improved stopping event queue threads

hpi1 git at videolan.org
Tue Apr 9 22:15:19 CEST 2013


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Tue Apr  9 12:03:42 2013 +0300| [1df32dd2737793e5089ab190b7716159b959138a] | committer: hpi1

Improved stopping event queue threads

> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=1df32dd2737793e5089ab190b7716159b959138a
---

 src/libbluray/bdj/java/java/awt/BDRootWindow.java |   14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/libbluray/bdj/java/java/awt/BDRootWindow.java b/src/libbluray/bdj/java/java/awt/BDRootWindow.java
index c5b5c13..4ceb78f 100644
--- a/src/libbluray/bdj/java/java/awt/BDRootWindow.java
+++ b/src/libbluray/bdj/java/java/awt/BDRootWindow.java
@@ -69,7 +69,7 @@ public class BDRootWindow extends Frame {
 
     public static void stopEventQueue(EventQueue eq) {
         EventDispatchThread t = eq.getDispatchThread();
-        if (t != null) {
+        if (t != null && t.isAlive()) {
 
             final long DISPOSAL_TIMEOUT = 5000;
             final Object notificationLock = new Object();
@@ -88,6 +88,18 @@ public class BDRootWindow extends Frame {
             }
 
             t.stopDispatching();
+            if (t.isAlive()) {
+                t.interrupt();
+            }
+
+            try {
+                t.join(1000);
+            } catch (InterruptedException e) {
+            }
+            if (t.isAlive()) {
+                org.videolan.Logger.getLogger("BDRootWindow").error("stopEventQueue() failed for " + t);
+                org.videolan.PortingHelper.stopThread(t);
+            }
         }
     }
 



More information about the libbluray-devel mailing list