Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


How to make thread sleep less than a millisecond on windows?



How to make thread sleep less than a millisecond on windows?..

Answer / Kramank Rajput

In Windows, the smallest granularity for thread sleep is 15.625 microseconds. However, you can work around this limitation by using the `time.perf_counter()` function from Python's time module to achieve sub-millisecond accuracy.nHere's an example:n``pythonnimport timenimport threadingnndef sleep_less_than_ms(ms):n start = time.perf_counter()n elapsed = 0n while elapsed < ms:n if time.perf_counter() - start >= ms:n breakn elapsed += 1e-6n nif __name__ == '__main__':n threading.Thread(target=sleep_less_than_ms, args=(500,)).start()`

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Windows General Interview Questions

How do I open the run command?

1 Answers  


Does windows 10 come with a spreadsheet program?

1 Answers  


Is windows coming out with a new operating system?

1 Answers  


Can I install windows 10 on android tablet?

1 Answers  


How do I run chkdsk on c drive?

1 Answers  


Why is my computer so slow all of a sudden windows 7?

1 Answers  


Is it ok to disable sysmain?

1 Answers  


Did windows 95 have ie?

1 Answers  


How to bring a window to the front?

1 Answers  


What is the minimum ram requirement for windows 10?

1 Answers  


Is it safe to delete system queued windows error reporting?

1 Answers  


How do I run a script in windows 10?

1 Answers  


Categories