Atomic Variables
In laboratory session 2, we observed that the increment operation (as demonstrated with the statement a+=2) is not an atomic operation (an operation that cannot be divided when executed by a thread). Java provides support for various data types (atomic types) that come with associated atomic operations (more details here and here). These are useful for use as counters or accumulators without the need for synchronization mechanisms.