• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Found problem in 1.5 book example

 
Nikolay Gannev
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I got my assignment a couple of days ago and started reading Andrew's book on SCJD 1.5...
I found a problem on page 99 - the implementation of run() method . Well I expected the code to be like the following below:

synchronized(this.lockA){
System.out.println(name + " : locked " + lockA );

delay(name);

System.out.println(name + " : trying to get " + lockB);
synchronized(this.lockB){

System.out.println(name + " : locked " + lockB);
}
}

this is how it looks in the book now:

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);
}
}

Please correct if I am wrong...
Is there any document that describes eventual syntax errors!

Thanks...
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, it looks as if you are correct. You can report such mistakes on the book's errata web page
You might even get a mention in the corrected printings

By the way, I believe such mistakes are there to find out if the readers are alert and really understanding what they are reading - so don't bash the authors too hard
[ December 29, 2005: Message edited by: Barry Gaunt ]
 
Nikolay Gannev
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Barry,

I already sent a note to apress.com...

Thanks!
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12014
220
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Nikolay,

Sigh. What's worse is that I even remember having a discussion with Jim regarding that particular bit of code and the names of the variables. I had fixed the real code (if you download it from the Apress website you will see how it is supposed to be) but somehow missed it in the book.

(Perhaps I should just go with Barry's explanation )

I will add this to the errata page (as soon as I find out how).

Regards, Andrew
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic