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

Apress Book "IceCreamMan.java" Question

 
Steve SL
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello:

In the book (Andrew & Terry), p.83 "IceCreamMan.java":

Line 26: sleep(1000);
Line 72: Thread.sleep( (long) (Math.random() * 1000)) ;

Anyone help me understand why Line 72 is adding "Thread" before the "sleep"?
Is it mandatory for the whole logic to work?
Thanks very much.

- Partial code listing below:

[ December 12, 2006: Message edited by: Barry Gaunt ]
 
Luc Feys
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would think it's by force of habit. Because it's considered to be better programming style to call static members using the class name the author has probably added it undeliberately (or forgotten to add it in the first case).

It shouldn't make any difference (unless there would be a new definition of the sleep(long) method in the 'IceCreamMan' class).

Luc
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Like Luc says. It's the sleep(1000) without the Thread prefix that's really the anomalie here. The Eclipse IDE will point these things out for you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic