本文介绍了Guava的ImmutableList.Builder线程安全吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Guava的ImmutableList.Builder的线程安全保证是什么?Javadocs不会说.

What are the thread safety guarantees for Guava's ImmutableList.Builder? The javadocs don't say.

推荐答案

虽然Guava不可变类是线程安全的,但其构建器却不是.对于大多数应用程序,只有一个线程将与任何特定的Builder实例进行交互.

While the Guava Immutable classes are threadsafe, their builders are not. For most applications, only one thread will interact with any particular Builder instance.

尽管通常不需要记录缺少线程安全性,但是对于Immutable集合构建器而言,这样的Javadoc可能很有意义.人们可能会惊讶于ImmutableList是线程安全的,而ImmutableList.Builder不是.

While the absence of thread-safety usually doesn't need to be documented, such Javadoc might make sense for the Immutable collection builders. People may be surprised that ImmutableList is threadsafe while ImmutableList.Builder isn't.

这篇关于Guava的ImmutableList.Builder线程安全吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 06:12