| Author |
Thread.sleep(0)
|
Drew Lane
Ranch Hand
Joined: May 13, 2001
Posts: 296
|
|
Is there any performance penalty by calling Thread.sleep(0)? I've got a program that lets the user define the wait period between animation frames and I'm wondering if it would be better to just bypass sleep() altogether if they select zero. Thanks, Drew
|
 |
Leslie Chaim
Ranch Hand
Joined: May 22, 2002
Posts: 336
|
|
|
What do you expect to gain with this extra logic?
|
Normal is in the eye of the beholder
|
 |
Jim Yingst
Wanderer
Sheriff
Joined: Jan 30, 2000
Posts: 18652
|
|
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
|
 |
 |
|
|
subject: Thread.sleep(0)
|
|
|