Threaded and atomic save of database