This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I am using thread concept for my application development, when i am trying to execute the thread it hast to listen form 120 seconds for check whether any command is came for process or not, during the 120 seconds the my CPU usage was very high, i have to reduce the utilization of the CPU usage.
Balaji Soundarajan wrote:
Here i don't want to make the thread to wait status, it has to monitor the command from the client simultaneously for 120 seconds with out using CPU usage.
That's exactly what wait/notify is for. The command thread calls wait() on some object. Then when a message arrives from the client, the client thread calls notify() on that same object. The command thread gets the notification and wakes up, processes the command, and calls wait() again to wait for another command.
Joined: Dec 29, 2004
I agree. You got to wait until the command comes from the client. once the command reaches, you can notify your waiting thread so that it can process the command.