I currently have a set of rules to create usernames based on a user's initials. This is not adjustable. So a user has 'xxx' as his initials. His username would be zzxxx1. The next user with the same initials would be zzxxx2 and so on. I'm using Java to generate the ids (useridCreation.jar). This jar is being called by a multi-threaded application (ITIM). So how would I go about reserving zzxxx1 until the first user is finished being created so as to not have duplicate usernames. This is a feed type situation where the usernames are being generated. I can pull up to 4 users/sec. I was thinking Vector, but I'm not too familiar with multi-threaded applications so I'm not sure how to approach that. SQL table is another option, but I feel like even with concurrent writing off, there would be some issues there. What about a file that I lock/unlock. Has anybody implemented a solid solution for this type of issue?
Edit: I forgot to mention this is a cluster environment.