This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
In the above programme I've commented out the synchronised block around wait() and notify()[I know it will give a run time exception] just for a hypotethic scenario; I don't seem to see the importance of lock in calling wait and notify; i.e. even without owning or releasing the lock, the waiting / notifying behaviour should happen. I know there is a flawin my thought process, please explain.
I will try it with a more complex example, to show, why it is useful to remind the programmer to use synchronisation. The following code contains a problem (Besides that it doesn't use synchronisation for wait and notify). Can you find it? [ August 11, 2007: Message edited by: Manfred Klug ]
Joined: Feb 15, 2007
Manfred Klug ,
Do you think wait,notify can be called out-side synchronized context ???
Joined: Jun 04, 2007
Originally posted by Srinivasan thoyyeti: Do you think wait,notify can be called out-side synchronized context
If you read the text, you will see, that I know that this will not work. It is only for demonstration purposes.