--- src/java/org/apache/lucene/search/TimeLimitedCollector.java.orig 2010-01-07 17:23:55.274171000 -0500 +++ src/java/org/apache/lucene/search/TimeLimitedCollector.java 2010-01-07 23:22:18.846167000 -0500 @@ -55,6 +55,8 @@ // See section 17 of the Java Language Specification for details. private volatile long time = 0; + private boolean runFlag = true; + /** * TimerThread provides a pseudo-clock service to all searching * threads, so that they can count elapsed time with less overhead @@ -69,7 +71,7 @@ public void run() { boolean interrupted = false; try { - while( true ) { + while( runFlag ) { // TODO: Use System.nanoTime() when Lucene moves to Java SE 5. time += resolution; try { @@ -92,6 +94,10 @@ public long getMilliseconds() { return time; } + + public void stopThread() { + runFlag = false; + } } /** @@ -216,4 +222,8 @@ public void setGreedy(boolean greedy) { this.greedy = greedy; } + + public static void stopThread() { + TIMER_THREAD.stopThread(); + } }