Joiner线程安全吗?

时间:2010-03-03 20:46:59

标签: java thread-safety guava

google collections Joiner线程是否安全?

2 个答案:

答案 0 :(得分:28)

是的!我们不打算重复SimpleDateFormat的错误。 : - )

Joiner需要获得与其姐妹班Splitter获得的类似文档升级,其中说:

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

答案 1 :(得分:16)

唯一的状态是

  private final String separator;

所以是的,它是线程安全的。