krazycoder / google-collections

Automatically exported from code.google.com/p/google-collections
Apache License 2.0
0 stars 0 forks source link

Document ImmutableMap's thread safety guarantees #256

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
It looks like ImmutableMap guarantees that its entries are fully visible across 
threads once it's 
constructed (since Entry objects are stored in final collections that are fully 
populated in the 
constructor). It would be nice if this was documented. I'm guessing the other 
immutable classes are 
as safe and could benefit from something like the following in their javadoc:

Entries of ImmutableXXX and their references are guaranteed to have visibility 
from other threads at 
least as up-to-date as they were at the point of construction of the 
ImmutableXXX.

Original issue reported on code.google.com by jheitm...@gmail.com on 9 Oct 2009 at 5:33

GoogleCodeExporter commented 9 years ago
I agree that it's worth emphasizing the advantages of immutability, and I think 
it 
could be done evem more simply by saying, "Instances of immutable types may be 
safely 
accessed from any thread without additional synchronization."

Original comment by tpeie...@gmail.com on 9 Oct 2009 at 6:04

GoogleCodeExporter commented 9 years ago
I like it.

Original comment by kevin...@gmail.com on 16 Oct 2009 at 9:07

GoogleCodeExporter commented 9 years ago
This issue has been moved to the Guava project (keeping the same id number). 
Simply replace 'google-collections' with 'guava-libraries' in your address 
bar and it should take you there.

Original comment by kevinb@google.com on 5 Jan 2010 at 11:09