I have a blocking priority queue which stores Objects of type Message, message has String[] data = new String[10]. Now I have to iterate over whole blocking Queue, check if its Object message's 2nd element is equal to 6th element of an incoming message.
The comparator of Messages is not based on 6th element which needs to be updated. Problem is that if I take out an object then how to put it at same position and if I use the code below to update it then anytime iter.next() is run it may start pointing to next Object.
Here is what I am trying.
public synchronized void updateAck(Message ackMessage)
{
Iterator iter = localQ.iterator(); // localQ is the blocking priority queue here
while(iter.hasNext())
{
if(((Message)iter.next()).data[2].equalsIgnoreCase(ackMessage.data[6]))
{
(Integer.parseInt((Message)iter.next()).data[6])+1);
}
}
}