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.