From 95028e2485f520a9263e779ea1340d433e414072 Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Fri, 27 Oct 2006 16:43:54 +0000 Subject: [PATCH] updatingConsensus, updatingConservation is static - only one thread can run the calculation at once, otherwise we'll go out of memory --- src/jalview/gui/AlignViewport.java | 73 +++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 35 deletions(-) diff --git a/src/jalview/gui/AlignViewport.java b/src/jalview/gui/AlignViewport.java index efce038..36f69a5 100755 --- a/src/jalview/gui/AlignViewport.java +++ b/src/jalview/gui/AlignViewport.java @@ -264,6 +264,21 @@ public class AlignViewport { try { + while (updatingConservation) + { + try + { + Thread.sleep(200); + } + catch (Exception ex) + { + ex.printStackTrace(); + } + } + + updatingConservation = true; + + int alWidth = alignment.getWidth(); if(alWidth<0) return; @@ -381,15 +396,15 @@ public class AlignViewport } - static ConservationThread conservationThread; + ConservationThread conservationThread; - static ConsensusThread consensusThread; + ConsensusThread consensusThread; boolean consUpdateNeeded = false; - boolean updatingConsensus = false; + static boolean updatingConsensus = false; - boolean updatingConservation = false; + static boolean updatingConservation = false; /** * DOCUMENT ME! @@ -399,21 +414,8 @@ public class AlignViewport if (alignment.isNucleotide() || conservation==null) return; - updatingConservation = true; - // javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { - while (conservationThread != null && conservationThread.isAlive()) - { - try - { - // Thread.sleep(100); - ap.repaint(); - } - catch (Exception ex) - {} - } - conservationThread = new ConservationThread(ap); - conservationThread.start(); - // } }); + conservationThread = new ConservationThread(ap); + conservationThread.start(); } /** @@ -421,22 +423,8 @@ public class AlignViewport */ public void updateConsensus(final AlignmentPanel ap) { - updatingConsensus = true; - - // javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { - while (consensusThread != null && consensusThread.isAlive()) - { - try - { - // Thread.sleep(100); - ap.repaint(); - } - catch (Exception ex) - {} - } - consensusThread = new ConsensusThread(ap); - consensusThread.start(); - // } }); + consensusThread = new ConsensusThread(ap); + consensusThread.start(); } @@ -449,6 +437,20 @@ public class AlignViewport } public void run() { + while (updatingConsensus) + { + try + { + Thread.sleep(200); + } + catch (Exception ex) + { + ex.printStackTrace(); + } + } + + updatingConsensus = true; + try { int aWidth = alignment.getWidth(); @@ -1510,6 +1512,7 @@ public class AlignViewport resetAllColourSchemes(); alignment.adjustSequenceAnnotations(); + } -- 1.7.10.2