rejigged jmol check thread to run prior to data loading thread to avoid classloader...
authorjprocter <Jim Procter>
Sat, 4 Apr 2009 11:17:16 +0000 (11:17 +0000)
committerjprocter <Jim Procter>
Sat, 4 Apr 2009 11:17:16 +0000 (11:17 +0000)
src/jalview/bin/JalviewLite.java

index cb8f4f7..9226dc4 100755 (executable)
@@ -305,6 +305,7 @@ public class JalviewLite extends Applet
   boolean embedded = false;
 
   private boolean checkForJmol = true;
+  private boolean checkedForJmol = false; // ensure we don't check for jmol every time the app is re-inited
 
   public boolean jmolAvailable = false;
 
@@ -397,9 +398,6 @@ public class JalviewLite extends Applet
       }
     }
 
-    LoadJmolThread jmolAvailable = new LoadJmolThread();
-    jmolAvailable.start();
-
     final JalviewLite applet = this;
     if (getParameter("embedded") != null
             && getParameter("embedded").equalsIgnoreCase("true"))
@@ -540,8 +538,14 @@ public class JalviewLite extends Applet
 
   class LoadJmolThread extends Thread
   {
+    private boolean running=false;
+
     public void run()
     {
+      if (running || checkedForJmol) {
+        return;
+      }
+      running=true;
       if (checkForJmol)
       {
         try
@@ -569,6 +573,13 @@ public class JalviewLite extends Applet
                   .println("Skipping Jmol check. Will use MCView (probably)");
         }
       }
+      checkedForJmol=true;
+      running=false;
+    }
+
+    public boolean notFinished()
+    {
+      return running || !checkedForJmol;
     }
   }
 
@@ -590,7 +601,6 @@ public class JalviewLite extends Applet
     String format;
 
     JalviewLite applet;
-
     private void dbgMsg(String msg)
     {
       if (applet.debug)
@@ -638,6 +648,13 @@ public class JalviewLite extends Applet
 
     public void run()
     {
+      LoadJmolThread jmolchecker = new LoadJmolThread();
+      jmolchecker.start();
+      while (jmolchecker.notFinished())
+      {
+        // wait around until the Jmol check is complete.
+        try { Thread.sleep(2); } catch (Exception e) {};
+      }
       startLoading();
     }