Hi,

>  I have two confused questions regarding Lucene implementation, hope
> someone can give me some clues.
> 
>   1. It's about the AttributeSource/AttributeSourceImpl implemenation.
> Seems like the default instance was kept as "static"
> in DefaultAttributeFactory. But we get these instances in analyzer directly. 
> In
> this point of view, analyzer implementation is not thread safe, right?
> Because each attributesourceimpl object will refer to same instance but
> without synchronization.

This is not a problem. Analyzers are threadsafe; every TokenStream instance is 
used only in one thread.
The DefaultAttributeFactory singleton is not a problem, as the instance is only 
used read-only and all members are final and the internal state of 
DefaultAttributeFactory instance does not change. The static cache inside 
DefaultAttributeFactory#getClassForInterface is thread safe, as it uses a 
concurrent map. The members of the map are Class<? extends AttributeImpl>; each 
AttributeImpl is created with newInstance() from the Class<? extends 
AttributeImpl> instance.

Uwe


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-user-h...@lucene.apache.org

Reply via email to