I am creating an application in Java in which there is a table in database which stores available access slots.

Basically when a user makes a request, the program should find a record in table which has an open(unused) slot. After the user's data is sent to him, that slot is marked as used and cannot be used anymore.

What I am confused about is, how to handle many simultaneous requests... For eg, if 2 requests come in at the same time, then isnt there a possibility of both of them picking up the same slot(record) from the table? How do I ensure that even though there are many simultaneous requests, each request picks a unique unused slot, and that all requests pick different unused slots.

One thing more, I do have many many slots, but it is important that no single slot be picked up by 2 different requests. However even this may change in future, if the number of requests rises tremendously...So I need a solution that is built to handle a huge number of requests in the manner that i have described.