[jboss-user] [JBossCache] - Queue structure

aditsu do-not-reply at jboss.com
Wed Nov 14 06:03:36 EST 2007


Hi, is it possible to implement a FIFO queue in the cache, so that multiple threads (or apps) can add and remove elements in order, without conflicting?
As I understand it, each node has a (Concurrent)HashMap of child nodes and a HashMap of data. HashMap is not particularly known for keeping the order of the entries, so there doesn't seem to be a way to, for example, get the "first" element.
Is there any feasible way to implement this kind of structure over the cache, without locking and writing excessively? I thought maybe I can keep a counter (also in the cache), and increment it for every element, then use the counter as a key in a HashMap (probably for child node names), then later use a for loop to get the elements in order, but it feels like reading and incrementing the counter could be troublesome.

Adrian

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4104479#4104479

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4104479



More information about the jboss-user mailing list