Java Utililty Methods AtomicLong

List of utility methods to do AtomicLong

Description

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

Method

voidjoinThreads()
join Threads
while (runningThreads.get() > 0) {
    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {
longlock()
lock
return threads.incrementAndGet();
booleanmax(AtomicLong x, long y)
max
for (;;) {
    long value = x.get();
    if (y > value) {
        if (!x.compareAndSet(value, y)) {
            continue;
        return true;
    } else {
...
longnanoTime()
Equivalent to System.nanoTime(), but based off the 1/1/1970 epoch like currentTimeMillis().
long custom = customTimeMs.get();
if (custom == -1)
    return System.nanoTime() + nanoTimeOffset;
else
    return custom * 1000000L;
voidprintProgress(final AtomicLong value)
print Progress
new Thread("printProgress") {
        setDaemon(true);
    @Override
    public void run() {
        long startValue = value.get();
        long startTime, time = System.currentTimeMillis();
...
longrandomSeed()
Returns a random seed generated by taking a unique increasing long, adding System#nanoTime() and scrambling the result using the finalisation step of Austin Appleby's MurmurHash3.
long seed = seedUniquifier.incrementAndGet() + System.nanoTime();
seed ^= seed >>> 33;
seed *= 0xff51afd7ed558ccdL;
seed ^= seed >>> 33;
seed *= 0xc4ceb9fe1a85ec53L;
seed ^= seed >>> 33;
return seed;
voidremoveCustomTime()
Clear any outstanding setCustomTimeMs override, so that subsequent calls to currentTimeMillis() will return the actual system clock.
customTimeMs.set(-1);
voidresetURICounter()
Resets the URI counter used by #getUniqueURIString() .
uriCounter.set(0);
voidrunThread(Runnable r)
run Thread
final Thread t = new Thread(r);
t.start();
runningThreads.incrementAndGet();
Thread t1 = new Thread(new Runnable() {
    public void run() {
        try {
            t.join();
            runningThreads.decrementAndGet();
...