Code example for AtomicLong

Methods: getAndIncrement

0
 
public class IdSpace { 
    private AtomicLong currentId = new AtomicLong(0);
     
    public long nextId() { 
        return currentId.getAndIncrement();
    } 
} 
Contextual code suggestions in your IDE  Get Codota for Java