wood burning stoves*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes mistake in andrew's book Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "mistake in andrew Watch "mistake in andrew New topic
Author

mistake in andrew's book

Maksym Odintsov
Greenhorn

Joined: Jan 22, 2009
Posts: 11
Page 117 deadlock example.

public void run() {
String name = Thread.currentThread().getName();
synchronized (lock1) {
System.out.println(name + ": locked " + lockA);
delay(name);
System.out.println(name + ": trying to get " + lockB);
synchronized (lock2) {
System.out.println(name + ": locked " + lockB);
}
}
I think you meant lockA and lockB intead of lock1 and lock2 inside of synchronized. I tested this example and it doesn't work unless the locks are changed.
P.S Thank you for the book, it's really helping.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: mistake in andrew's book
 
Similar Threads
Misprint in Andrw's Book
Avoiding deadlock situations in java
wait() releases all locks?
Wait question from K&B threads chapter
Found problem in 1.5 book example