On 02/25/2015 03:41 PM, Xiangrong Fang wrote:

Can I use Sleep() in a thread to give up cpu time to other threads running at the same time
AFAIK:

Sleep(n) makes the thread give up CPU for _at_least_ n milliseconds

Sleep(0) makes it give up it's current time slice and is due to be re-scheduled rather soon.

sleep will not necessary give time to other threads. it also might give the time to other programs running on the system.

In an SMP OS multiple threads run at the same time, anyway. Sleep might make a thread run that before was waiting for a CPU.

-Michael
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to