In the code below, in the main method I am synchronizing on the
String array parameter of the main method. The code gives an IllegalMonitorStateException when trying to call wait on commented line.
I know that a
thread has to be owner of the object on which it is synchronizing but in this case I am unable to figure out the reason of this exception as to how main thread is not the owner of the array.
Probably I could not understand the conditions as to when a thread owns an object's lock. Please clarify.