[JENKINS-24763] Prevent thread starvation in OldDataMonitor by reducing scope of synchronization

Supercedes #1399 
Note that there a race condition here: we acquire the lock and get `localCopy` which includes some project (say); then we go through our loop and save that project; then someone POSTs a new `config.xml` for the project with some old data, causing `remove` to be called and the project to be added to `data` (in the new version); then we hit the end of this method and the project is removed from `data` again, even though it again has old data.

In practice I think this condition is extremely unlikely, and not a major problem even if it does occur: just means the user will be prompted to discard less than they should have been (and would see the warning again after next restart). So I do not think you need to do anything about it except document the possibility in a comment for future generations.

If you do want to fix it, the best I can think of is to delete _everything_ from `data` at the start of this method, keeping a copy; then at the end of this method, readd those savables which we did _not_ save. That would ensure that anything added by `remove` in the meantime stays there. It also defends better against concurrent calls to `doDiscard`.