lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Cocula Remi" <rcoc...@sopragroup.com>
Subject RE: Is IndexSearcher thread safe?
Date Tue, 01 Mar 2005 14:29:20 GMT


>Additional question.
>If I'm sharing one instance of IndexSearcher between different threads 
>Is it good to just to drop this instance to GC.
>Because I don't know if some thread is still using this searcher or done 
>with it.

Note that as far as one of the threads keep a reference on the IndexSearcher it can not be
garbage collected.
Perhaps you meant that you do not know how a thread can declare that it does no more need
the indexSearcher.

To cope this that I created an IndexSercher pool.
The pool contains a list of IndexSearchers and each one is associated with a counter. 
To get an IndexSearcher reference one must request it to the pool and then the counter is
incremented.
(To make it cleaner I had the idea to replace IndexSearcher references in the pool with proxy
objects thus the pool will never distribute references of IndexSearchers to clients objects.
The counter can be manage inside the proxy.)

The pool has the ability to close and dereference an IndexSearcher when it is no more used
(counter=0).

Hope it helps.



---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org


Mime
View raw message