public interface Counter
thread-safe implementation
and a non thread-safe implementation
.
There are also factories for both counters:
SIMPLE
and THREAD_SAFE
.Modifier and Type | Interface and Description |
---|---|
static interface |
Counter.Creator
Interface for counter creation.
|
Modifier and Type | Field and Description |
---|---|
static Counter.Creator |
SIMPLE
Simple counter creator.
|
static Counter.Creator |
THREAD_SAFE
Thread safe counter creator.
|
Modifier and Type | Method and Description |
---|---|
int |
add(Counter counter)
Add something to the counter.
|
int |
add(int add)
Add something to the counter.
|
int |
add1()
Add 1 to counter.
|
int |
getValue()
Get the value.
|
void |
setValue(int value)
Set the value.
|
int |
substract(Counter counter)
Substract something from the counter.
|
int |
substract(int sub)
Substract something from the counter.
|
int |
substract1()
Substract 1 from counter.
|
static final Counter.Creator SIMPLE
SimpleCounter
static final Counter.Creator THREAD_SAFE
ThreadSafeCounter
int add(int add)
add
- value to addint add(Counter counter)
counter
- counter which value is addedint add1()
int substract(int sub)
sub
- value to substractint substract(Counter counter)
counter
- counter which value is substractedint substract1()
int getValue()
void setValue(int value)
value
- new value