lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Uwe Schindler" <>
Subject RE: Questions about lucene TokenStream
Date Sun, 04 Nov 2012 22:07:00 GMT

>  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>


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message