pgras is right that immutability will correct things, but that would also be difficult. You could just block it all, but it could be a performance issue. I can think of two good ideas.
First you need to use ReadWriteLock (this requires 1.5 or newer). Since your breakpoint can acquire a read lock, it can be guaranteed that everything is in order, but when no one reads performance, it should be pretty good. This is still a pretty crude lock, so you can also do # 2 ...
Secondly, to sort it out. Each area of ββthe program can contain its own map (map for GUI files, map for user settings, map for hardware settings, whatever). Everyone will have a castle, and everything will be as usual. When the time came for the checkpoint, the checkpointer would capture ALL locks (so that everything would be consistent), and then do it. The trap is here - you have determined the lock order of locks (say, in alphabetical order), otherwise you will run into deadlocks.
If the cards are orthogonal to each other (updates for one do not require updates for the other to be consistent), then the simplest thing is to redirect updates to the central βbackupβ card in the checkpointer, unlike something you described.
My biggest question for you would be, is this a problem (performance wise)? Are updates often, or are they rare? This will help advise on something, since my last idea (previous paragraph) may be slow, but it is easy and does not matter.
There is a fantastic book called Java Concurrency in Practice , which is basically a binary version of Java. It discusses how to figure out this material and strategies in order to avoid problems or make them easier to solve. If you are going to make more threads, it is very useful to read.
In fact, if your key values ββare orthogonal to each other, then everything is very simple. The ConcurrentMap interface (there are features like ConcurrentHashMap ) will solve your problems, as they can make changes atomically, so readers will not see conflicting data. But if you have two (or more) keys that need to be updated at the same time, this will not cover you.
Hope this helps. Access to shared data structures is complex stuff.