R
richnjones
Hi there,
Ive written some code that works but Im not too happy with. Can anyone
give me some advice on how to make it better.
Problem:
At time = X call method A()
methodA() returns straight away
Wait for time = Y
call methodB()
Solution:
So what Ive done is:
while (notAtTimeX()){
sleep(10ms)
}
methodA()
while (notAtTimeX()){
sleep(10ms)
}
methodB()
Because methodA() doesnt block I have to these horrible while loops
that query the clock and sleep until it gets to the appropriate time.
I was thinking maybe using wait() and notify() might be a better
pattern. I hope this is clear. Ive simplified the problem a bit but
hopefully it will still be relevant for my problem
What do you think?
Thanks
R
Ive written some code that works but Im not too happy with. Can anyone
give me some advice on how to make it better.
Problem:
At time = X call method A()
methodA() returns straight away
Wait for time = Y
call methodB()
Solution:
So what Ive done is:
while (notAtTimeX()){
sleep(10ms)
}
methodA()
while (notAtTimeX()){
sleep(10ms)
}
methodB()
Because methodA() doesnt block I have to these horrible while loops
that query the clock and sleep until it gets to the appropriate time.
I was thinking maybe using wait() and notify() might be a better
pattern. I hope this is clear. Ive simplified the problem a bit but
hopefully it will still be relevant for my problem
What do you think?
Thanks
R