Added a lock, instead of synchrnizing teh whole section. We now prtect
the write and read as a whole (that should be a fix for DIRMINA-779)