dvas0004 / NerdNotes

A collection of notes: things I'd like to remember while reading technical articles, technical questions I couldn't answer, and so on.
12 stars 0 forks source link

Java Atomic Variables #86

Open dvas0004 opened 5 years ago

dvas0004 commented 5 years ago

Atomic variables have special "transactional" or "atomic" operations such as getAndSet which allow you to do two operations (like checking the value of a variable, and then setting it), in a transactional/atomic fashion - i.e. the operations (plural) are guaranteed to all succeed or all fail. Atomic variables are usually used in multithreaded sections of code which for performance reasons are avoiding locks such as synchronized blocks