Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

mistake in andrew's book

 
Maksym Odintsov
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic