From b8bb1bb364809be6063443f683a0ba4ebc1b0fe6 Mon Sep 17 00:00:00 2001 From: orbiter Date: Sat, 13 Jun 2009 23:54:52 +0000 Subject: [PATCH] join with a timeout does not cause that the corresponding thread is stopped after the time-out. It does only cause that the waiting is stopped. Here we need additionally a signal to the thread to stop after we finished waiting. git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@6069 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- source/de/anomic/tools/DidYouMean.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/source/de/anomic/tools/DidYouMean.java b/source/de/anomic/tools/DidYouMean.java index 5013b44fe..50aa0ef72 100644 --- a/source/de/anomic/tools/DidYouMean.java +++ b/source/de/anomic/tools/DidYouMean.java @@ -26,6 +26,7 @@ public class DidYouMean { private final IndexCell index; private String word; private int len; + private boolean stop; private Thread ChangingOneLetter; private Thread AddingOneLetter; @@ -38,6 +39,7 @@ public class DidYouMean { this.word = ""; this.len = 0; this.index = index; + this.stop = false; this.ChangingOneLetter = new ChangingOneLetter(); this.AddingOneLetter = new AddingOneLetter(); @@ -61,7 +63,9 @@ public class DidYouMean { this.ChangingOneLetter.join(TIMEOUT); this.AddingOneLetter.join(TIMEOUT); } catch (InterruptedException e) { - } + } finally { + stop = true; + } this.set.remove(word.toLowerCase()); Log.logInfo("DidYouMean", "found "+this.set.size()+" terms; execution time: "+(System.currentTimeMillis()-startTime)+"ms"); @@ -82,6 +86,7 @@ public class DidYouMean { set.add(s); count++; } + if (stop) return; } } } @@ -90,16 +95,17 @@ public class DidYouMean { private class DeletingOneLetter extends Thread { // tests: len public void run() { - String s; - int count = 0; + String s; + int count = 0; for(int i=0; i