In which object should I implement wait()/notify()?
- by Christopher Francisco
I'm working in an Android project with multithreading. Basically I have to wait to the server to respond before sending more data.
The data sending task is delimited by the flag boolean hasServerResponded so the Thread will loop infinitely without doing anything until the flag becomes true.
Since this boolean isn't declared as volatile (yet), and also looping without doing anything wastes resources, I thought maybe I should use AtomicBoolean and also implement wait() / notify() mechanism.
Should I use the AtomicBoolean object notify() and wait() methods or should I create a lock Object?