Is there java.util.concurrent equivalent for WeakHashMap?

前端 未结 6 1141
轻奢々
轻奢々 2020-12-08 13:38

Can the following piece of code be rewritten w/o using Collections.synchronizedMap() yet maintaining correctness at concurrency?

Collections.sy         


        
6条回答
  •  心在旅途
    2020-12-08 14:01

    I don't believe there is. In fact the javadoc suggests using Collections.synchronizedMap()

    "Like most collection classes, this class is not synchronized. A synchronized WeakHashMap may be constructed using the Collections.synchronizedMap method."

提交回复
热议问题