Usually I work with multithreading in java.
I started with Petterson's and Dekker's mutual exclusion and volatile to guarantee that the value of variables dont' be saved in a cache and everything were ok.
Then I tried with semaphores and also volatile variables, that were ok too.
Nowadays I usually use both methods and blocks synchronized, but when I only need a variable to be accessed in mutual exclusion and the value need to be "volatile", I use the package java.util.concurrent.atomic such as AtomicIntegerArray or AtomicInteger.
Then, if you read about this in the Java API:
https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/atomic/package-summary.html
You will find this:
"The specifications of these methods enable implementations to employ efficient machine-level atomic instructions that are available on contemporary processors. However on some platforms, support may entail some form of internal locking. Thus the methods are not strictly guaranteed to be non-blocking -- a thread may block transiently before performing the operation"
This is something that makes me feel a little confusing.
Does it means that is not secure to use atomic objects?
Could this be the reason of an unexpected behavior in a concurrent program?