By Alvin Alexander. Last updated: June 13, 2015
The links shows a way to subclass java.util.Random using an XORShift generator, with the Java source code looking like this:
public class XORShiftRandom extends Random { private long seed = System.nanoTime(); public XORShiftRandom() { } protected int next(int nbits) { // N.B. Not thread-safe! long x = this.seed; x ^= (x << 21); x ^= (x >>> 35); x ^= (x << 4); this.seed = x; x &= ((1L << nbits) -1); return (int) x; } }
There is also more documentation at this XORShift random number generators page.