61 return lo; 62 } 63 64 /** 65 * Computes a linear congruential random number a random number 66 * of times. 67 */ 68 public static int compute2(int x) { 69 int loops = (x >>> 4) & 7; 70 while (loops-- > 0) { 71 x = (x * 2147483647) % 16807; 72 } 73 return x; 74 } 75 76 /** 77 * An actually useful random number generator, but unsynchronized. 78 * Basically same as java.util.Random. 79 */ 80 public static class SimpleRandom { 81 private final static long multiplier = 0x5DEECE66DL; 82 private final static long addend = 0xBL; 83 private final static long mask = (1L << 48) - 1; 84 static final AtomicLong seq = new AtomicLong(1); 85 private long seed = System.nanoTime() + seq.getAndIncrement(); 86 87 public void setSeed(long s) { 88 seed = s; 89 } 90 91 public int next() { 92 long nextseed = (seed * multiplier + addend) & mask; 93 seed = nextseed; 94 return ((int)(nextseed >>> 17)) & 0x7FFFFFFF; 95 } 96 } 97 98 public static class BarrierTimer implements Runnable { 99 public volatile long startTime; 100 public volatile long endTime; 101 public void run() { 102 long t = System.nanoTime(); 103 if (startTime == 0) | 61 return lo; 62 } 63 64 /** 65 * Computes a linear congruential random number a random number 66 * of times. 67 */ 68 public static int compute2(int x) { 69 int loops = (x >>> 4) & 7; 70 while (loops-- > 0) { 71 x = (x * 2147483647) % 16807; 72 } 73 return x; 74 } 75 76 /** 77 * An actually useful random number generator, but unsynchronized. 78 * Basically same as java.util.Random. 79 */ 80 public static class SimpleRandom { 81 private static final long multiplier = 0x5DEECE66DL; 82 private static final long addend = 0xBL; 83 private static final long mask = (1L << 48) - 1; 84 static final AtomicLong seq = new AtomicLong(1); 85 private long seed = System.nanoTime() + seq.getAndIncrement(); 86 87 public void setSeed(long s) { 88 seed = s; 89 } 90 91 public int next() { 92 long nextseed = (seed * multiplier + addend) & mask; 93 seed = nextseed; 94 return ((int)(nextseed >>> 17)) & 0x7FFFFFFF; 95 } 96 } 97 98 public static class BarrierTimer implements Runnable { 99 public volatile long startTime; 100 public volatile long endTime; 101 public void run() { 102 long t = System.nanoTime(); 103 if (startTime == 0) |