开发者

How to create a synchronized version of Google Guava's TreeMultimap

Does anyone know how to开发者_Go百科 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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜