List of utility methods to do AtomicLong
void | joinThreads() join Threads while (runningThreads.get() > 0) { try { Thread.sleep(1000); } catch (InterruptedException e) { |
long | lock() lock return threads.incrementAndGet();
|
boolean | max(AtomicLong x, long y) max for (;;) { long value = x.get(); if (y > value) { if (!x.compareAndSet(value, y)) { continue; return true; } else { ... |
long | nanoTime() 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; |
void | printProgress(final AtomicLong value) print Progress new Thread("printProgress") { setDaemon(true); @Override public void run() { long startValue = value.get(); long startTime, time = System.currentTimeMillis(); ... |
long | randomSeed() 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; |
void | removeCustomTime() Clear any outstanding setCustomTimeMs override, so that subsequent calls to currentTimeMillis() will return the actual system clock. customTimeMs.set(-1); |
void | resetURICounter() Resets the URI counter used by #getUniqueURIString() . uriCounter.set(0); |
void | runThread(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(); ... |