I have already asked this before how to generate auto increment ID Generate auto increment number by using Java.
I have used below code:
private static final AtomicInteger count = new AtomicInteger(0);
uniqueID = count.incrementAndGet();
The previous code working fine but the problem is count
static variable. For this static its never start to 0
again, its always start with the last increment id. That is the issue.
Is there any alternative way except AtomicInteger
?
Another issue is that I am working on GWT so AtomicInteger
is not available in GWT.
So I have to find another way to do that.