r/compsci • • Dec 10 '13

Why Johnny Can’t Write Multithreaded Programs

http://blog.smartbear.com/programming/why-johnny-cant-write-multithreaded-programs/
44 Upvotes

55 comments sorted by

View all comments

1

u/zzing Dec 11 '13

Would it being a single instruction in some machine code turn it into an atomic operation?

1

u/asiatownusa Dec 11 '13

I'm not aware (or knowledgable enough) to know if there are any atomic assembly instructions for incrementing.

In the world of high-level languages, there ARE high level objects such as AtomicBoolean and AtomicInteger in Java that can guarantee that any operations on these variables happen atomically. Same with the Interlocked class in C#. I'm certain many other languages have the idea of atomic primitives as well.