Concurrency Gotchas 4
Volatile counters: "++"/"--" is not an atomic operation, so volatile is not sufficient. count++ is "read, write, read", so reads and writes will propagate, but will not be atomic
Composing atomic actions doesn't work: repeated calls to a thread-safe class aren't atomic, so multiple calls to a thread-safe class aren't thread safe. Slapping a synchronized lock on things is odd, because you're adding a different (distinct) lock from the thread-safe class itself. If your class uses synchronized methods, it locks on "this", which is available both inside and outside of the app, and that works. Better is to use encapsulated methods: ConcurrentHashMap.
Assigning 64 bit values is not atomic on 32 bit JVMs.