All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.mentaqueue.util.PauseSupport Maven / Gradle / Ivy

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