|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.hazelcast.util.counters.MwCounter
public final class MwCounter
A Counter
that is thread-safe; so can be incremented by multiple threads concurrently.
The MwCounter is not meant for a huge amount of contention. In that case it would be better to create a counter
on the LongAdder
.
This counter does not provide padding to prevent false sharing.
Method Summary | |
---|---|
long |
get()
Gets the current value. |
void |
inc()
Increments the counter by one. |
void |
inc(int amount)
Increments the counter by the given amount. |
static MwCounter |
newMwCounter()
Creates a new MwCounter with 0 as initial value. |
static MwCounter |
newMwCounter(int initialValue)
Creates a new MwCounter with the given initial value. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Method Detail |
---|
public long get()
Counter
get
in interface Counter
public void inc()
Counter
inc
in interface Counter
public void inc(int amount)
Counter
inc
in interface Counter
amount
- the amount to increase the counter with.public String toString()
toString
in class Object
public static MwCounter newMwCounter()
public static MwCounter newMwCounter(int initialValue)
initialValue
- the initial value.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |