Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
Can some one explain why the first thread runs printing A and B , where as the second thread throws an exception. The source is http://www.javaranch.com
Is it because in the second program the object doesnot have a refernce name?
[ September 10, 2008: Message edited by: Nabila Mohammad ]
The future belongs to those who believe in the beauty of their dreams.Dream BIG!
The second one throws MonitorStateException. This is because when you do this
synchronized(new Object())//separate object { new Object.notifyAll();//separate object }
as you may know that you must hold the lock of the object that you call wait, notify and notifyAll on. But in this case, the synchronized block uses a different object and the notifyAll call uses a separate object of the Object class..