How to create a synchronized version of Google Guava TreeMultimap

Does anyone know how to create a thread safe instance of TreeMultimap using TreeMultimap.create() ?

+6
source share
2 answers

The Guava Multimaps contains static methods for creating and decoding 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()) 
+15
source

Similarly, if you need a synchronized version of ListMultiMap , you can use:

 Multimaps.synchronizedListMultimap(ArrayListMultimap.create()); 

Google Guava White Paper

+1
source

Source: https://habr.com/ru/post/893765/


All Articles