Recursive problem...
- by Chronos
Guys,
I'm new to java and multithreading..... and I have a following problem:
I have two classes running in two different threads. Class A and Class B.
Class A has the method "onNewEvent()". Once that method is invoked, it will ask class B to do some work. As soon as B finishes the work it invokes onJobDone() method of the class A.
Now... here comes the problem... what I want is to create new job within onJobDone() method and to send it again to B.
here is what I do (pseudo code) ... in the sequence of execution
A.onNewEvent(){
//create job
//ask B to do it
B.do()
}
B.do{
// Do some stuff
A.jobDone()
}
A.onJobDOne(){
B.do() //doItAgain
// print message "Thank you for doing it"
}
The problem is... that message "Thank you for doing it" never gets printed... in fact, when onJobDone() method is invoked, it invokes B.do()... because B.do() is very fast, it invokes onJobDone() immediatly... so execution flow never comes to PRINT MESSAGE part of code...
I suppose this is one of the nasty multithreading problems....
any help would be appreciated.