From 0bc9297afd18a3e2b412364bf1af426570555b9a Mon Sep 17 00:00:00 2001 From: gmungoc Date: Mon, 18 May 2020 16:01:54 +0100 Subject: [PATCH] JAL-3463 avoid Thread.sleep() as not supported in SwingJS --- src/jalview/ws/DBRefFetcher.java | 46 +++++++++++++------------------------- 1 file changed, 15 insertions(+), 31 deletions(-) diff --git a/src/jalview/ws/DBRefFetcher.java b/src/jalview/ws/DBRefFetcher.java index 6b8843d..7daa7b4 100644 --- a/src/jalview/ws/DBRefFetcher.java +++ b/src/jalview/ws/DBRefFetcher.java @@ -20,6 +20,16 @@ */ package jalview.ws; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.List; +import java.util.Map; +import java.util.StringTokenizer; +import java.util.Vector; + import jalview.analysis.AlignSeq; import jalview.api.FeatureSettingsModelI; import jalview.bin.Cache; @@ -36,17 +46,6 @@ import jalview.gui.OOMWarning; import jalview.util.DBRefUtils; import jalview.util.MessageManager; import jalview.ws.seqfetcher.DbSourceProxy; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.Hashtable; -import java.util.List; -import java.util.Map; -import java.util.StringTokenizer; -import java.util.Vector; - import uk.ac.ebi.picr.model.UPEntry; import uk.ac.ebi.www.picr.AccessionMappingService.AccessionMapperServiceLocator; @@ -74,8 +73,6 @@ public class DBRefFetcher implements Runnable CutAndPasteTransfer output = new CutAndPasteTransfer(); - boolean running = false; - /** * picr client instance */ @@ -225,24 +222,13 @@ public class DBRefFetcher implements Runnable */ public void fetchDBRefs(boolean waitTillFinished) { - // TODO can we not simply write - // if (waitTillFinished) { run(); } else { new Thread(this).start(); } - - Thread thread = new Thread(this); - thread.start(); - running = true; - if (waitTillFinished) { - while (running) - { - try - { - Thread.sleep(500); - } catch (Exception ex) - { - } - } + run(); + } + else + { + new Thread(this).start(); } } @@ -295,7 +281,6 @@ public class DBRefFetcher implements Runnable throw new Error(MessageManager .getString("error.implementation_error_must_init_dbsources")); } - running = true; long startTime = System.currentTimeMillis(); if (progressWindow != null) { @@ -498,7 +483,6 @@ public class DBRefFetcher implements Runnable { listener.finished(); } - running = false; } /** -- 1.7.10.2