12345678910111213141516171819202122232425262728293031323334353637383940 |
- package com.its.bis.process;
- import com.its.app.utils.Converter;
- import java.util.concurrent.atomic.AtomicLong;
- public class Counter {
- private AtomicLong counter = new AtomicLong(0L);
- public Counter() {
- }
- public long reset() {
- return this.counter.getAndSet(0L);
- }
- public long reset(long value) {
- return this.counter.getAndSet(0L);
- }
- public long increment() {
- return this.counter.incrementAndGet();
- }
- public long add(long value) {
- return this.counter.addAndGet(value);
- }
- public long decrement() {
- return this.counter.decrementAndGet();
- }
- public long get() {
- return this.counter.get();
- }
- public String toString() {
- return Converter.getSize(this.counter.doubleValue());
- }
- }
|