This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
That's one of the tricks the exam can play on you.
sleep is a static method of Thread. It always acts on the current thread. In any sensible implementation you would just use Thread.sleep().
But, transistor is a Thread object (because Transistor extends Thread). You can refer to a static member via an instance of the class. So it's a perfectly acceptable piece of code as far as the compiler is concerned. It's bad style, but the compiler doesn't care about that.
Tom Reilly wrote:To make the current thread sleep:
What's the use of currentThread() here?? As Matthew pointed out, sleep() is a static method in Thread class, so you can directly call it as Thread.sleep(), it doesn't matter on which Thread instance you call it, it'll always sleep the Thread that called the method...