I'm working a program that will have a bunch of threads processing data.
Each thread needs to grab the next available ID, increment that ID by 1 for the next thread and do this in a thread-safe way.
Is this an instance where I would use a mutex? Should I use a Queue.Synchronized instead and fill it up with all 300,000 ID's or is this unecessary?
Should I just have a single integer and somehow lock the retrieval and updating of that number so thread1 comes in, gets "20" as the next ID and then increments it to "21" while another thread is waiting?
What is the best-practice for this use-case?