public final class ThreadSafeLongCounter extends java.lang.Object implements LongCounter
This class is thread safe!
LongCounter.Creator
SIMPLE, THREAD_SAFE
Constructor and Description |
---|
ThreadSafeLongCounter()
Default constructor.
|
ThreadSafeLongCounter(int val)
Constructor.
|
ThreadSafeLongCounter(LongCounter count)
Copy constructor.
|
Modifier and Type | Method and Description |
---|---|
long |
add(long add)
Add something to the counter.
|
long |
add(LongCounter counter)
Add something to the counter.
|
long |
add1()
Add 1 to counter.
|
long |
getValue()
Get the value.
|
void |
setValue(long val)
Set the value.
|
long |
subtract(long sub)
Subtract something from the counter.
|
long |
subtract(LongCounter counter)
Subtract something from the counter.
|
long |
subtract1()
Subtract 1 from counter.
|
java.lang.String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
add, add, subtract, subtract
public ThreadSafeLongCounter()
public ThreadSafeLongCounter(int val)
val
.val
- init valuepublic ThreadSafeLongCounter(@NotNull LongCounter count)
count
- counter to be copiedpublic long add(long add)
LongCounter
add
in interface LongCounter
add
- value to addpublic long add(@NotNull LongCounter counter)
LongCounter
add
in interface LongCounter
counter
- counter which value is addedpublic long add1()
LongCounter
add1
in interface LongCounter
public long subtract(long sub)
LongCounter
subtract
in interface LongCounter
sub
- value to subtractpublic long subtract(@NotNull LongCounter counter)
LongCounter
subtract
in interface LongCounter
counter
- counter which value is subtractedpublic long subtract1()
LongCounter
subtract1
in interface LongCounter
public long getValue()
LongCounter
getValue
in interface LongCounter
public void setValue(long val)
LongCounter
setValue
in interface LongCounter
val
- new value@NotNull public java.lang.String toString()
toString
in class java.lang.Object