JAL-1333 more refinements - deadlocks still possible with this version
[jalview.git] / src / ext / edu / ucsf / rbvi / strucviz2 / ChimeraManager.java
index a82a6fb..95ea0d7 100644 (file)
@@ -627,7 +627,7 @@ public class ChimeraManager
     }
     return values;
   }
-
+  private volatile boolean busy=false;
   /**
    * Send a command to Chimera.
    * 
@@ -645,7 +645,13 @@ public class ChimeraManager
     {
       return null;
     }
-
+    while (busy)
+    {
+      try {
+        Thread.sleep(25);
+      } catch (InterruptedException q) {};
+    }
+    busy=true;
     chimeraListenerThreads.clearResponse(command);
     String text = command.concat("\n");
     // System.out.println("send command to chimera: " + text);
@@ -661,13 +667,17 @@ public class ChimeraManager
       logger.warn("Unable to execute command: " + text);
       logger.warn("Exiting...");
       clearOnChimeraExit();
+      busy=false;
       return null;
     }
     if (!reply)
     {
+      busy=false;
       return null;
     }
-    return chimeraListenerThreads.getResponse(command);
+    List<String> rsp = chimeraListenerThreads.getResponse(command);
+    busy=false;
+    return rsp;
   }
 
   public StructureManager getStructureManager()