How to generate unique ID that is integer in java that not guess next number?
How unique does it need to be?
If it's only unique within a process, then you can use an AtomicInteger and call incrementAndGet() each time you need a new value.
AtomicInteger
incrementAndGet()
2.1m questions
2.1m answers
60 comments
57.0k users