Data integrity first

Multi-threaded code can be complex. With the advent of java.util.concurrent, multi-threaded code can now usually be written at a higher level than was previously possible. However, multi-threaded code can still be complex.

One should likely treat the basic thread-safety of a class as being fundamental. Performance optimizations and "tricky" code should likely be avoided unless they are really necessary.

As usual, when faced with various implementation decisions, one should weigh carefully the pros and cons, such as:

For example, using a read-write lock with a Map might be tempting in a given circumstance, but you'll likely find that a ConcurrentHashMap works just fine.