There are many moments where our multi-threaded code needs to gurantee only one code path is executing at a time. That’s why we have locks, semaphores, mutexes, and so on. But those are all pretty complicated. Vincent H recently was reviewing someone’s code, and they found a far more elegant solution, which simply uses booleans. For example, you could whip up a wait loop with a simple block like this:
When
By passing //thedailywtf.com/images/highlight/highlight.pack.js
[Advertisement]
ProGet supports your applications, Docker containers, and third-party packages, allowing you to enforce quality standards across all components. Download and see how!
via Tumblr CodeSOD: Waaaaaiiiiit for it…
0 Comments
Leave a Reply. |
About Us:Dive deep into a topic with Appeared, learning both how and why things work. Come and be a part of our group if you are looking for a collection of articles on software development and computer programming. I am an experienced and enthusiastic computer programmer who prefers high-level languages and simple solutions. Other Profiles:
|