Code example for AtomicLong

Methods: getAndIncrement

0
    private Long id;
    private DoctorSpeciality speciality;
    public static AtomicLong incrementalId = new AtomicLong();
     
    public Doctor() { 
        this.id = Doctor.incrementalId.getAndIncrement();
    } 
 
    
 
 
    public Doctor(DoctorSpeciality speciality) {
        this(); 
        this.speciality = speciality;
    } 
 
    public Long getId() {
        return id;
    } 
 
    public void setId(Long id) {