4 Replies Latest reply on Nov 14, 2007 12:00 PM by Manik Surtani

    Queue structure

    Adrian Sandor Newbie

      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.