Reputation: 80194
Is google collections Joiner thread safe?
Upvotes: 16
Views: 2106
Reputation: 40851
Yes! We're not about to repeat the mistakes of SimpleDateFormat
. :-)
Joiner
needs to receive a similar documentation upgrade to what its sister class Splitter
got, which says:
* <p><b>Warning: splitter instances are always immutable</b>; a configuration
* method such as {@code omitEmptyStrings} has no effect on the instance it
* is invoked on! You must store and use the new splitter instance returned by
* the method. This makes splitters thread-safe, and safe to store as {@code
* static final} constants . . .
Upvotes: 29
Reputation: 76281
Its only state is a
private final String separator;
So yes it's threadsafe.
Upvotes: 16