public final class SharedModuloCounter extends ModuloCounter implements IShared
DEFAULT_MAX_VALUE, DEFAULT_MIN_VALUE
Constructor and Description |
---|
SharedModuloCounter(long maxValue)
Initializes a new instance of the class.
|
SharedModuloCounter(long maxValue,
long minValue)
Initializes a new instance of the class.
|
Modifier and Type | Method and Description |
---|---|
long |
getValue()
Returns the counter value
|
void |
lock()
Locks the object
|
long |
next()
Increments the counter and returns the next value
|
void |
reset()
Resets the counter to the minimum value
|
void |
unlock()
Unlocks the object.
|
getMaxValue, getMinValue
public SharedModuloCounter(long maxValue)
maxValue
- The maximum counter value.java.lang.IllegalArgumentException
- When the maximum is less than or equal to minimum, or equal to Long.MAX_VALUEpublic SharedModuloCounter(long maxValue, long minValue)
maxValue
- The maximum counter value.minValue
- The minimum counter value.java.lang.IllegalArgumentException
- When the maximum is less than or equal to minimum, or equal to Long.MAX_VALUEpublic long getValue()
getValue
in interface ICounter
getValue
in class ModuloCounter
public void unlock()
public long next()
next
in interface ICounter
next
in class ModuloCounter
public void reset()
reset
in interface ICounter
reset
in class ModuloCounter