Code example for AtomicLong

Methods: decrementAndGet

0
    public ListenerRef addCancellationListener(Runnable listener) {
        final ListenerRef result = wrapped.addCancellationListener(listener);
        final Runnable unregTask = Tasks.runOnceTask(new Runnable() {
            @Override 
            public void run() { 
                regCount.decrementAndGet();
            } 
        }, false); 
 
        regCount.incrementAndGet();
        return new ListenerRef() { 
            @Override 
            public boolean isRegistered() { 
                return result.isRegistered();
            } 
 
            @Override 
            public void unregister() { 
                unregTask.run();
                result.unregister();
            }