Java Utililty Methods AtomicInteger

List of utility methods to do AtomicInteger

Description

The list of methods to do AtomicInteger are organized into topic(s).

Method

voidresetCounter()
reset Counter
counter = new AtomicInteger(0);
voidresetCounters()
reset Counters
counters.clear();
MapresetExceptionCount()
reset Exception Count
Map<String, AtomicInteger> cur = exceptionCount;
exceptionCount = new ConcurrentHashMap<String, AtomicInteger>();
criticalCount.set(0);
exceptionTimefrom = System.currentTimeMillis();
singleMax = 0;
singleMaxName = "";
return getCountMap(cur);
booleansetBit(AtomicInteger i, int mask)
Atomically sets a bit (or bits) for an AtomicInteger.
boolean success = false;
while (!success) {
    int current = i.get();
    if ((current & mask) != 0) {
        return false;
    int next = current | mask;
    success = i.compareAndSet(current, next);
...
voidsetBitByValue(final AtomicInteger ai, final int value)
set Bit By Value
setBitByIndex(ai, Integer.numberOfTrailingZeros(value));
booleansetBitIfUnsetByIndex(final AtomicInteger ai, final int n)
set Bit If Unset By Index
if (n >= Integer.SIZE) {
    throw new IllegalArgumentException("Out of int bit index boundary (31)");
int bitInt = 1 << n;
int oldValue = ai.get();
int newValue = oldValue | bitInt;
while (newValue != oldValue && !ai.compareAndSet(oldValue, newValue)) {
    oldValue = ai.get();
...
voidstoreStoreBarrier()
store Store Barrier
ai.lazySet(-1);
longtimeToId(long timeInMillis)
time To Id
if (serial.intValue() > 9900 * BASE) {
    serial.set(BASE);
return timeInMillis / 1000 * 1000000000 + serial.getAndAdd(BASE) + RANDOM.nextInt(BASE);
Maptokenize(String string)
Parse the given string and return a list of the whitespace-delimited tokens that it contains mapped to the number of occurrences of each token.
Map<String, AtomicInteger> result = new HashMap<String, AtomicInteger>();
String[] tokens = string.split("\\s"); 
for (String token : tokens) {
    if (token.length() == 0) {
        continue;
    String tokenDown = token.toLowerCase();
    AtomicInteger count = result.get(tokenDown);
...
intuniqueSequenceId()
Generates a process-wide unique sequence number.
return sequence.incrementAndGet();