Moving all threads to the runnable state:
As a final topic, we look at the difference between notify and notifyAll. The notify method causes the scheduler to arbitrarily select one of the threads currently waiting in the blocked state for the lock on a particular object and moves it into the runnable state. The notifyAll method causes all of the threads currently in the blocked state and waiting for the lock on a particular object to be moved into the runnable state. Remember that being in the runnable state does not mean that a thread will run, but simply that it has the opportunity to be selected to go into the running state. So, superficially, it would seem that there is no difference between notify and notifyAll - the end result is that one of the originally blocked threads will be able to go, at some point, into the running state.
The most important grounds for using notifyAll rather than notify is that it is safer, particularly if we are not entirely sure how threads are interacting with each other.
If notify is called and the single arbitrary thread that gets unblocked is the wrong one, it will find it cannot proceed and call wait again. If it is the wrong thread but proceeds anyway, the system is in an incorrect state. At this point it is possible that none of the runnable threads can make progress, because the conditions are wrong, and the only threads that would have been able to continue are still blocked. The runnable threads then become blocked one by one, until all are blocked never to be released.
Java Assignment Help - Java Homework Help
Struggling with java programming language? Are you not finding solution for your Moving all threads to the runnable state homework and assignments? Live Moving all threads to the runnable state experts are working for students by solving their doubts & questions during their course studies and training program. We at Expertsmind.com offer Moving all threads to the runnable state homework help, java assignment help and Moving all threads to the runnable state projects help anytime from anywhere for 24x7 hours. Computer science programming assignments help making life easy for students.
Why Expertsmind for assignment help
- Higher degree holder and experienced experts network
- Punctuality and responsibility of work
- Quality solution with 100% plagiarism free answers
- Time on Delivery
- Privacy of information and details
- Excellence in solving java programming language queries in excels and word format.
- Best tutoring assistance 24x7 hours