I'm running into mutex issues with my Queue class under load which I'm at a loss to figure out why they are happening.
objects = new ArrayList<Object>();
public synchronized int getSize(){
return objects.size();
}
public synchronized Object dequeue(){
if(getSize()==0){
try {
wait();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return objects.remove(0);
}
public synchronized void enqueue(Object o){
objects.add(o);
notify();
}
It seems as if the dequeue method after a while is causing Java.lang.IndexOutOfBoundsException which to me looks like threads have been able to call the dequeue method multiple times when it shouldnt be. Any ideas ???
W