I have a requirement to generate confirmation numbers by incrementing the existing highest confirmation number in the Mongo collection. The application makes use of multi threading and multiple threads might read the same document and increment the confirmation number by one and write it back to the database. Therefore, there can be multiple documents with the same confirmation number. What will be a good way to solve this? Even if I do findAndModify, there can be multiple threads that read the same document with the highest confirmation number, right? If I am right, Mongo will only prevent writing to the document at the same time, but it will let the other threads read the document. If I am wrong, what will Mongo return instead? The document with the next highest confirmation number?