org.mentaqueue.util.PauseSupport Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of menta-queue Show documentation
Show all versions of menta-queue Show documentation
A super fast inter-thread transfer queue.
The newest version!
package org.mentaqueue.util;
import java.util.Random;
import java.util.concurrent.locks.LockSupport;
public class PauseSupport {
private static final Random RANDOM = new Random();
private static int dummy;
public static int assignment(long loops) {
for(int i = 0; i < loops; i++) {
PauseSupport.dummy = i;
}
return PauseSupport.dummy;
}
public static int random(long loops) {
for(int i = 0; i < loops; i++) {
PauseSupport.dummy = RANDOM.nextInt(1000);
}
return PauseSupport.dummy;
}
public static final long lock(long nanos) {
LockSupport.parkNanos(nanos);
return nanos;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy