Add a queue to synchronize database access for multiple threads