16

谷歌收藏 Joiner 线程安全吗?

4

2 回答 2

29

是的!我们不打算重蹈覆辙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 . . .
于 2010-03-03T23:48:39.533 回答
16

它唯一的状态是

  private final String separator;

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

于 2010-03-03T20:53:12.560 回答