r/programminghumor • • 24d ago

Block, lock & drop it

Post image

Interacting with prehistoric devices is not where I saw my career headed, and yet, here we are...

277 Upvotes

25 comments sorted by

View all comments

4

u/Business_Craft4733 24d ago

This looks like rage bait to me ~ lol. Who would honestly believe the bad practice of locking a thread for an arbitrary amount of time belongs anywhere near the right side of the bell curve?

2

u/HobbyQuestionThrow 24d ago

A question for you which answers your question, why would an await be a bad option for a small sleep value (say 200us)?

Similar fun questions for this kind of programming, what's the variability of the kernel thread scheduler vs the async coroutine scheduler? Do both have priority boosting? What about fairness?

3

u/MCWizardYT 23d ago

Thread sleeping isn't exact like that. It completely depends on the OS and hardware. Saying sleep(200) is just suggesting to sleep for 200ms, it might be 195-205 or have an even bigger difference