Thread.wait()
If I have a Runnable with a do{}while loop within it, and I have an
ArrayList of objects which is being operated on in the Event Dispatch
thread, and within the loop within my Runnable, I Thread.wait() until that
ArrayList is down to 0 elements within it, to continue through the
loop.....as my code below (should, I believe) perform, can anyone tell me,
why, then, when my arrayList IS 0 size, the do{}while loop does not seem to
continue, i.e. I dont seem to come out of the wait() state? Must I do
something to break out of the wait() state aside from having
arrayList.size()==0 ? Thanks, RalphVince
public ArrayList arrayList =new ArrayList();
//arrayList is assigned some values
Runnable studyinteractive = new Runnable(){
public void run(){
do{
//...something
try{
synchronized(this) {
while(arrayList.size()>0) //arrayList is being
worked on in another thread
wait();
}
}catch(InterruptedException interruptedexception) { }
}while(somethingIsTrue);
};
};
javax.swing.SwingUtilities.invokeLater(studyinteractive);