I needed a very simple lock system for a software demo for operation on HashMap, instead of using ReentrantLock from java.util.concurrent.locks i chose to use Atomic classes from java.util.concurrent.atomic.* .
My demo has a very LONG blocking thread that writes on a shared HashMap, the following class permits me to tune the sleep time for the lock without using a syncronized queue.
Continue reading “Java code example: simple singleton lock using with Atomic variables” »