有没有这个定义的并发版本Java Guava collections Map
Is there a concurrent version of this definition Java Guava collections Map
这个定义Guava collections Map有并发版本吗?
ListMultimap<DuplicateKey,Integer> map =
Multimaps.newListMultimap(
Maps.<DuplicateKey, Collection<Integer>>newTreeMap(),
new Supplier<List<Integer>>() {
public List<Integer> get() {
return Lists.newArrayList();
}
});
没有并发多图实现,但您可以用 Multimaps.synchronizedListMultimap
视图包装它,其中:
Returns a synchronized (thread-safe) multimap backed by the specified multimap.
你的情况:
ListMultimap<DuplicateKey,Integer> synchronizedMultimap =
Multimaps.synchronizedListMultimap(map);
阅读 complete javadoc 以了解有关同步访问视图的注意事项:
In order to guarantee serial access, it is critical that all access to the backing multimap is accomplished through the returned multimap.
请注意,根据 issue #135 on Github,Guava 本身没有通用的并发多图实现。
这个定义Guava collections Map有并发版本吗?
ListMultimap<DuplicateKey,Integer> map =
Multimaps.newListMultimap(
Maps.<DuplicateKey, Collection<Integer>>newTreeMap(),
new Supplier<List<Integer>>() {
public List<Integer> get() {
return Lists.newArrayList();
}
});
没有并发多图实现,但您可以用 Multimaps.synchronizedListMultimap
视图包装它,其中:
Returns a synchronized (thread-safe) multimap backed by the specified multimap.
你的情况:
ListMultimap<DuplicateKey,Integer> synchronizedMultimap =
Multimaps.synchronizedListMultimap(map);
阅读 complete javadoc 以了解有关同步访问视图的注意事项:
In order to guarantee serial access, it is critical that all access to the backing multimap is accomplished through the returned multimap.
请注意,根据 issue #135 on Github,Guava 本身没有通用的并发多图实现。