hanlei0000000009 wrote:I need my program sleep 1 microsecond, but Sleep() can not do this.
Neither can any other API do this (under Windows). Windows was never designed to provide this kind of functionality (it is not a real-time OS).
If you use something like
, your program may sleep for 2 milliseconds, may be 3, or 4, or say even 100 ms. There's no guarantee about this. The thread scheduler tries its levels best to put your thread to an 'unschedulable' state for as close as possible, to what you've asked. But, it can almost never be exact.
So, while Windows cannot even promise you the precision of milliseconds, you can forget microseconds, which is 1000 times the precision of milliseconds!