Code example for AtomicLong

Methods: set

0
package carrental.simulate; 
 
import java.util.Observable; 
import java.util.concurrent.atomic.AtomicBoolean; 
import java.util.concurrent.atomic.AtomicLong; 
 
public class SecondsCounter extends Observable {
 
    private AtomicLong seconds = new AtomicLong();  // the count
    private AtomicBoolean running = new AtomicBoolean();
    public OperationScheduler ticker;
 
    public SecondsCounter(double speed, long secs, boolean run) { // constructor
        seconds.set(secs);
        running.set(run);
        ticker = new OperationScheduler(this, speed);
    } 
 
    public void set(long s) {
        seconds.set(s);
        setChanged(); 
        notifyObservers();
    }