consider that i created three threads and make a call to add method
consider a situation one thread is in wait state,second one is in blocked state
when runnable thread notify the waiting thread and releases the lock
will both waiting and blocked thread enter the runnable state
if it is,which one get preference to acquire the lock
In this example all thread will enter a wait state and never change. But if you add another function which notifies the threads then one of them is chosen to be awakened. The choice is arbitrary and occurs at the discretion of the implementation. Which is a direct quote from the javadoc.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.