Hi, what is the best way to stop a thread and wait for a statement (or a method) to be executed a certain number of times by another thread? I was thinking about something like this (let "number" be an int):
number = 5;
while (number > 0) {
synchronized(number) { number.wait(); }
}
...
synchronized(number) {
number--;
number.notify();
}
Obviously this wouldn't work, first of all because it seems you can't wait() on a int type. Furthermore, all other solutions that come to my java-naive mind are really complicated for such a simple task. Any suggestions? (Thanks!)