ArrayListMultimap Thread Safety

665 views
Skip to first unread message

dsin...@chariotsolutions.com

unread,
Sep 16, 2013, 9:34:24 AM9/16/13
to guava-...@googlegroups.com
Hi all,

I am reading the API docs and code for ArrayListMultimap. It states the following in the javadoc "This class is not threadsafe when any concurrent operations update the multimap. Concurrent read operations will work correctly. To allow concurrent update operations, wrap your multimap with a call to {@link Multimaps#synchronizedListMultimap}." After looking at the source code, I am not seeing how this code is thread safe with even a single writer and at least one reader. There are no happens before relationships in the code to ensure that a given write will be visible to a reader. Also, the underlying HashMap is totally not safe for a writer and reader at the same time. 

I am misunderstanding the statement in the javadoc regarding the thread safety of this data structure?

thanks

dave

Chris Povirk

unread,
Sep 16, 2013, 9:51:43 AM9/16/13
to dsin...@chariotsolutions.com, guava-discuss
Your analysis is correct. The doc is intended to say as much, but the
phrasing isn't great. We'll see what we can do.
Reply all
Reply to author
Forward
0 new messages