logoalt Hacker News

mrkeentoday at 6:12 PM1 replyview on HN

A race condition:

  Two processes intend to add two to a number.

  They each read the current value.

  Then they each write back the value which is two bigger then the original.
If you instead use private fields and public getters/setters, or use actors to form a protective bubble around the mutable state, you get...

The exact same thing but with more boilerplate.


Replies

hackyhackytoday at 7:23 PM

The key feature of Erlang-style actors is that messages are enqueued and processed serially, thus eliminating race conditions of this type.

show 1 reply