Adding lock/synchronization to make sure that RMI calls are thread safe