Lucene QueryParser in multiple threads: synchronize or construct new each time?
问题 I have a web application where users submit queries to a Lucene index. The queries are parsed by a Lucene QueryParser. I learned the hard way that QueryParser is not thread-safe. Is it better to use a single QueryParser instance, and synchronize on calls to its parse() method? Or is it better to construct a new instance for each query? (Or would I be better served by a pool of QueryParser s?) I know that in general questions like this depend on the particulars and require profiling, but maybe