top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Why wait and notify method should be called in loop in Java?

+2 votes
1,209 views
Why wait and notify method should be called in loop in Java?
posted Mar 25, 2014 by Pushpak Chauhan

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

+1 vote

It is not mandatory to call wait and notify in a loop, it can be called in different synchronized method.

answer Mar 25, 2014 by Amit Kumar
0 votes

to prevent doing task, if condition is not true and thread is awake due to false alarms, checking conditions in loop ensures that processing is only done when business logic allows.

answer Mar 26, 2014 by Ashwini Miraj
...