posted 21 years ago
Is there any performance penalty by calling Thread.sleep(0)?
Well, it takes a tiny bit longer than not calling any method. It probably behaves like a Thread.yield() - it 's not guaranteed to have any effect, but it creates an opportunity for any other waiting threads to run. (Which they could do anyway if the JVM feels like it.) I suspect that it really doesn't matter much whether you put in extra logic to avoid calling sleep(0) - so I wouldn't bother unless you find that there's a problem.
"I'm not back." - Bill Harding, Twister