Multithreading

Lock, Monitor, Semaphore

Lock

A lock allows only one thread to enter the part that’s locked and the lock is not shared with any other processes. A mutex is the same as a lock but it can be system wide (shared by multiple processes).

(more…)

Advertisements

Volatile Keyword

We typically use volatile keyword when we share variables with more than one thread in a multi-threaded environment, and we want to avoid any memory inconsistency errors due to the caching of these variables in the CPU cache. (more…)