开发者

Persistent hash-map, concurrent JDBM

开发者 https://www.devze.com 2023-03-04 23:29 出处:网络
I tested JDBM2 which is really a great API to persist data d开发者_StackOverflowirectly in a tree- or hash-map. On the project site it is written that it does not support concurrent access. So my ques

I tested JDBM2 which is really a great API to persist data d开发者_StackOverflowirectly in a tree- or hash-map. On the project site it is written that it does not support concurrent access. So my question is: Are there similar open source APIs for Java available which support concurrent read and write operations?

Thanks


I guess a basic feature the questions implies is inter-jvm communication? If that is the case, I have successfully used hazelcast.

See for example this question that although different has valuable information.


Java has a way of wrapping an existent hash map and returning a synchronized map; however you will have to write the synchronization yourself: Collections#synchronizedMap

It is quite easy to extend an HashMap or implement the Map interface to enforce some synchronization on get() and put(), however iterators are more tricky.

There's also a ConcurrentHashMap but it has some limitations, depending on what you want to do.

The simple approach is to use Collections#synchronizedMap and add the synchronization code yourself.

0

精彩评论

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