I am getting a NoSuchElementException
sometimes when removing from a queue. Do I need to use locks/waits/some other delay mechanism?
I've provided a rough translation of the code.
Thread with Queue
public void run(){
while(true){
if(queue.size()>=2){
a = queue.remove();
b = queue.remove();
//DoesSomeWorkHereWhichWorks
//Writes to MVAR's
}
}
Thread which writes to the queue
public void run(){
while(x>0){
//Does something which works
QueueThread.add(this);
//Take from mvars
}
}
Much appreciated, please go easy on me, i'm new to programming :)