Does anyone know how to create a thread safe instance of TreeMultimap with
TreeMultimap.create()
?
The Guava Multimaps
class contains static methods for creating and decorating Multimaps, similar to what the Collections
class in java.util provides for Collections and Maps.
In your case, you should use:
Multimaps.synchronizedSortedSetMultimap(TreeMultimap.create())
Similarly, if you need to get synchronized version of ListMultiMap
, you could use:
Multimaps.synchronizedListMultimap(ArrayListMultimap.create());
Google Guava Official doc
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With