Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Guava's ImmutableList.Builder thread safe?

Tags:

guava

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

like image 821
Brian Harris Avatar asked May 20 '10 03:05

Brian Harris


1 Answers

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

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.

like image 141
Jared Levy Avatar answered Sep 28 '22 09:09

Jared Levy