Example here have to be split one per file, because they are either non-deterministic or take a perceptible amount of time to run.
TODO:
-
ConcurrentMapand other concurrent collectionsreplace: replaces only if the value exists / equals an older value. Does the check and insert atomically.
-
AtomicIntegerand family.Vs
volatile boolean: http://stackoverflow.com/questions/3786825/volatile-boolean-vs-atomicboolean Same asvolatile int, but with less compound operations. -
CountDownLatch -
ThreadLocal -
ThreadLocalRandom -
Executor-
ExecutorService
-
-
ForkJoinTaskRecursiveAction
Sources:
The synchronization primitives provided by the Java language are:
volatilefield modifier keywordsynchronizedmethod modifier or (TODO block modifier?) keywordObject.wait(),Object.notify()andObject.notifyAll()magic class methods
Besides those, there are many more convenient higher level interfaces provided by the JCL under java.util.concurrent:
- synchronized containers like
LinkedBlockingQueue - atomic types under java.util.concurrent.atomic:
AtomicInteger, etc. - locks under java.util.concurrent.atomic