Sleep or Yield in a infinite loop
I need to code an infinite loop. What is the best way to pause
the
thread for a while.
Sleep : The thread would go to the "sleep" state for the specified amount of time.
Yield: The thread would move from running state to ready state
run()
{
while(true)
{
//do something
Thread.sleep(1000);
OR
Thread.yield();
}
}
Does yield have any problem in a preemptive scheduling system.(like NT)
Thanks
Gobiraj