Search code examples
c#.netmultithreadinginterlocked

Does the name "Interlocked" have some particular meaning?


The Interlocked class provides easy access to atomic operations such as fetch and add and compare and swap.

MSDN says that this class:

Provides atomic operations for variables that are shared by multiple threads.

My question is: why is it called "Interlocked"? Is it supposed to mean something?


Solution

  • http://www.oxforddictionaries.com/definition/english/interlock

    A device or mechanism for connecting or coordinating the function of different components: a safety interlock to stop the blades spinning

    http://en.wikipedia.org/wiki/Interlock_(engineering)

    An interlock is a device used to prevent undesired states in a state machine, which in a general sense can include any electrical, electronic, or mechanical device or system. In most applications an interlock is used to help prevent a machine from harming its operator or damaging itself by stopping the machine when tripped. Household microwave ovens are equipped with interlock switches which disable the magnetron if the door is opened. Similarly household washing machines will interrupt the spin cycle when the lid is open. Interlocks also serve as important safety devices in industrial settings, where they protect employees from devices such as robots, presses, and hammers. While interlocks can be something as sophisticated as curtains of infrared beams and photodetectors, they are often just switches.

    That is what it does. It prevents undesirable states caused by reckless variable mutation.