Merge branch 'JAL-3878_ws-overhaul-3' into with_ws_overhaul-3
[jalview.git] / src / jalview / viewmodel / AlignmentViewport.java
index 5ad956f..0e3bb9e 100644 (file)
@@ -74,6 +74,9 @@ import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledThreadPoolExecutor;
 
 /**
  * base class holding visualization and analysis attributes and common logic for
@@ -995,6 +998,20 @@ public abstract class AlignmentViewport
     return false;
   }
 
+  private ScheduledExecutorService serviceExecutor = Executors.newSingleThreadScheduledExecutor();
+
+  /**
+   * Get a default scheduled executor service which can be used by
+   * services and calculators to run parallel jobs associated with this
+   * viewport.
+   * 
+   * @return default service executor of that viewport
+   */
+  public ScheduledExecutorService getServiceExecutor()
+  {
+    return serviceExecutor;
+  }
+
   public void setAlignment(AlignmentI align)
   {
     this.alignment = align;
@@ -1024,11 +1041,14 @@ public abstract class AlignmentViewport
     gapcounts = null;
     calculator.shutdown();
     calculator = null;
+    serviceExecutor.shutdown();
+    serviceExecutor = null;
     residueShading = null; // may hold a reference to Consensus
     changeSupport = null;
     ranges = null;
     currentTree = null;
     selectionGroup = null;
+    colSel = null;
     setAlignment(null);
   }