• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Found problem in 1.5 book example

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Barry,

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

Thanks!
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic