wait for a method to be called
Wich is the best way to implement the "// wait till codeFill() is called from some other object" part of this algorithm?:
public class SomeObject {
public void someMethod() {
// exec code A
codaA();
// exec code B
codeB();
// exec code C
codeC();
// wait till codeFill() is called from some other object...
// process the filled data
codeProcessFill();
}
}
[443 byte] By [
Arathron] at [2007-9-30 23:25:59]

That's preciselly the matter. Think of it as if someMethod() can be called at any moment from another object but it needs codeFill() to be called to complete, as it needs the information obtained externally by codeFill() and return with some result after processCodeFill().
Maybe codeFill is an event from a user, an accept button for example, the method must wait till some user accepts before completion.
So i need a way to 'hang' on codeFill and not continue till this method is called from some other object.
(In the example codeFill could be acceptButtonPressed event, or a comboValueChanged and and processCodeFill() would process it)
Thanxs for the reply.
public class SomeObject {
public void someMethod() {
// exec code A
codaA();
// exec code B
codeB();
// exec code C
codeC();
// wait till codeFill() is called from some other ther object...
wait();
// process the filled data
codeProcessFill();
}
void codeFill(){
notify();
}
}
There should be enough rope here for you to hang yourself with now ;)
Thanks a lot!
I didn't realice before it was some kind of the producer-consumer pattern, isn't it?
codeFill() produces and codeProcessFill() consumes. I just needed to put the thread to sleep till the producer awakes it.
That solved the problem, new comments or suggestions are welcome.
And again, thanks a lot for the replys!