Tabnine Logo
ThreadLocalRandom.next
Code IndexAdd Tabnine to your IDE (free)

How to use
next
method
in
org.glassfish.grizzly.utils.ThreadLocalRandom

Best Java code snippets using org.glassfish.grizzly.utils.ThreadLocalRandom.next (Showing top 12 results out of 315)

origin: org.glassfish.grizzly/grizzly-core

/**
 * Returns a pseudorandom, uniformly distributed value
 * between 0 (inclusive) and the specified value (exclusive).
 *
 * @param n the bound on the random number to be returned.  Must be
 *        positive.
 * @return the next value
 * @throws IllegalArgumentException if n is not positive
 */
public long nextLong(long n) {
  if (n <= 0)
    throw new IllegalArgumentException("n must be positive");
  // Divide n by two until small enough for nextInt. On each
  // iteration (at most 31 of them but usually much less),
  // randomly choose both whether to include high bit in result
  // (offset) and whether to continue with the lower vs upper
  // half (which makes a difference only if odd).
  long offset = 0;
  while (n >= Integer.MAX_VALUE) {
    int bits = next(2);
    long half = n >>> 1;
    long nextn = ((bits & 2) == 0) ? half : n - half;
    if ((bits & 1) == 0)
      offset += n - nextn;
    n = nextn;
  }
  return offset + nextInt((int) n);
}
origin: javaee/grizzly

/**
 * Returns a pseudorandom, uniformly distributed value
 * between 0 (inclusive) and the specified value (exclusive).
 *
 * @param n the bound on the random number to be returned.  Must be
 *        positive.
 * @return the next value
 * @throws IllegalArgumentException if n is not positive
 */
public long nextLong(long n) {
  if (n <= 0)
    throw new IllegalArgumentException("n must be positive");
  // Divide n by two until small enough for nextInt. On each
  // iteration (at most 31 of them but usually much less),
  // randomly choose both whether to include high bit in result
  // (offset) and whether to continue with the lower vs upper
  // half (which makes a difference only if odd).
  long offset = 0;
  while (n >= Integer.MAX_VALUE) {
    int bits = next(2);
    long half = n >>> 1;
    long nextn = ((bits & 2) == 0) ? half : n - half;
    if ((bits & 1) == 0)
      offset += n - nextn;
    n = nextn;
  }
  return offset + nextInt((int) n);
}
origin: javaee/grizzly

/**
 * Returns a pseudorandom, uniformly distributed value
 * between 0 (inclusive) and the specified value (exclusive).
 *
 * @param n the bound on the random number to be returned.  Must be
 *        positive.
 * @return the next value
 * @throws IllegalArgumentException if n is not positive
 */
public long nextLong(long n) {
  if (n <= 0)
    throw new IllegalArgumentException("n must be positive");
  // Divide n by two until small enough for nextInt. On each
  // iteration (at most 31 of them but usually much less),
  // randomly choose both whether to include high bit in result
  // (offset) and whether to continue with the lower vs upper
  // half (which makes a difference only if odd).
  long offset = 0;
  while (n >= Integer.MAX_VALUE) {
    int bits = next(2);
    long half = n >>> 1;
    long nextn = ((bits & 2) == 0) ? half : n - half;
    if ((bits & 1) == 0)
      offset += n - nextn;
    n = nextn;
  }
  return offset + nextInt((int) n);
}
origin: org.glassfish.grizzly/grizzly-websockets-server

/**
 * Returns a pseudorandom, uniformly distributed value
 * between 0 (inclusive) and the specified value (exclusive).
 *
 * @param n the bound on the random number to be returned.  Must be
 *        positive.
 * @return the next value
 * @throws IllegalArgumentException if n is not positive
 */
public long nextLong(long n) {
  if (n <= 0)
    throw new IllegalArgumentException("n must be positive");
  // Divide n by two until small enough for nextInt. On each
  // iteration (at most 31 of them but usually much less),
  // randomly choose both whether to include high bit in result
  // (offset) and whether to continue with the lower vs upper
  // half (which makes a difference only if odd).
  long offset = 0;
  while (n >= Integer.MAX_VALUE) {
    int bits = next(2);
    long half = n >>> 1;
    long nextn = ((bits & 2) == 0) ? half : n - half;
    if ((bits & 1) == 0)
      offset += n - nextn;
    n = nextn;
  }
  return offset + nextInt((int) n);
}
origin: javaee/grizzly

/**
 * Returns a pseudorandom, uniformly distributed value
 * between 0 (inclusive) and the specified value (exclusive).
 *
 * @param n the bound on the random number to be returned.  Must be
 *        positive.
 * @return the next value
 * @throws IllegalArgumentException if n is not positive
 */
public long nextLong(long n) {
  if (n <= 0)
    throw new IllegalArgumentException("n must be positive");
  // Divide n by two until small enough for nextInt. On each
  // iteration (at most 31 of them but usually much less),
  // randomly choose both whether to include high bit in result
  // (offset) and whether to continue with the lower vs upper
  // half (which makes a difference only if odd).
  long offset = 0;
  while (n >= Integer.MAX_VALUE) {
    int bits = next(2);
    long half = n >>> 1;
    long nextn = ((bits & 2) == 0) ? half : n - half;
    if ((bits & 1) == 0)
      offset += n - nextn;
    n = nextn;
  }
  return offset + nextInt((int) n);
}
origin: javaee/grizzly

/**
 * Returns a pseudorandom, uniformly distributed value
 * between 0 (inclusive) and the specified value (exclusive).
 *
 * @param n the bound on the random number to be returned.  Must be
 *        positive.
 * @return the next value
 * @throws IllegalArgumentException if n is not positive
 */
public long nextLong(long n) {
  if (n <= 0)
    throw new IllegalArgumentException("n must be positive");
  // Divide n by two until small enough for nextInt. On each
  // iteration (at most 31 of them but usually much less),
  // randomly choose both whether to include high bit in result
  // (offset) and whether to continue with the lower vs upper
  // half (which makes a difference only if odd).
  long offset = 0;
  while (n >= Integer.MAX_VALUE) {
    int bits = next(2);
    long half = n >>> 1;
    long nextn = ((bits & 2) == 0) ? half : n - half;
    if ((bits & 1) == 0)
      offset += n - nextn;
    n = nextn;
  }
  return offset + nextInt((int) n);
}
origin: javaee/grizzly

/**
 * Returns a pseudorandom, uniformly distributed value
 * between 0 (inclusive) and the specified value (exclusive).
 *
 * @param n the bound on the random number to be returned.  Must be
 *        positive.
 * @return the next value
 * @throws IllegalArgumentException if n is not positive
 */
public long nextLong(long n) {
  if (n <= 0)
    throw new IllegalArgumentException("n must be positive");
  // Divide n by two until small enough for nextInt. On each
  // iteration (at most 31 of them but usually much less),
  // randomly choose both whether to include high bit in result
  // (offset) and whether to continue with the lower vs upper
  // half (which makes a difference only if odd).
  long offset = 0;
  while (n >= Integer.MAX_VALUE) {
    int bits = next(2);
    long half = n >>> 1;
    long nextn = ((bits & 2) == 0) ? half : n - half;
    if ((bits & 1) == 0)
      offset += n - nextn;
    n = nextn;
  }
  return offset + nextInt((int) n);
}
origin: javaee/grizzly

/**
 * Returns a pseudorandom, uniformly distributed value
 * between 0 (inclusive) and the specified value (exclusive).
 *
 * @param n the bound on the random number to be returned.  Must be
 *        positive.
 * @return the next value
 * @throws IllegalArgumentException if n is not positive
 */
public long nextLong(long n) {
  if (n <= 0)
    throw new IllegalArgumentException("n must be positive");
  // Divide n by two until small enough for nextInt. On each
  // iteration (at most 31 of them but usually much less),
  // randomly choose both whether to include high bit in result
  // (offset) and whether to continue with the lower vs upper
  // half (which makes a difference only if odd).
  long offset = 0;
  while (n >= Integer.MAX_VALUE) {
    int bits = next(2);
    long half = n >>> 1;
    long nextn = ((bits & 2) == 0) ? half : n - half;
    if ((bits & 1) == 0)
      offset += n - nextn;
    n = nextn;
  }
  return offset + nextInt((int) n);
}
origin: javaee/grizzly

/**
 * Returns a pseudorandom, uniformly distributed value
 * between 0 (inclusive) and the specified value (exclusive).
 *
 * @param n the bound on the random number to be returned.  Must be
 *        positive.
 * @return the next value
 * @throws IllegalArgumentException if n is not positive
 */
public long nextLong(long n) {
  if (n <= 0)
    throw new IllegalArgumentException("n must be positive");
  // Divide n by two until small enough for nextInt. On each
  // iteration (at most 31 of them but usually much less),
  // randomly choose both whether to include high bit in result
  // (offset) and whether to continue with the lower vs upper
  // half (which makes a difference only if odd).
  long offset = 0;
  while (n >= Integer.MAX_VALUE) {
    int bits = next(2);
    long half = n >>> 1;
    long nextn = ((bits & 2) == 0) ? half : n - half;
    if ((bits & 1) == 0)
      offset += n - nextn;
    n = nextn;
  }
  return offset + nextInt((int) n);
}
origin: javaee/grizzly

/**
 * Returns a pseudorandom, uniformly distributed value
 * between 0 (inclusive) and the specified value (exclusive).
 *
 * @param n the bound on the random number to be returned.  Must be
 *        positive.
 * @return the next value
 * @throws IllegalArgumentException if n is not positive
 */
public long nextLong(long n) {
  if (n <= 0)
    throw new IllegalArgumentException("n must be positive");
  // Divide n by two until small enough for nextInt. On each
  // iteration (at most 31 of them but usually much less),
  // randomly choose both whether to include high bit in result
  // (offset) and whether to continue with the lower vs upper
  // half (which makes a difference only if odd).
  long offset = 0;
  while (n >= Integer.MAX_VALUE) {
    int bits = next(2);
    long half = n >>> 1;
    long nextn = ((bits & 2) == 0) ? half : n - half;
    if ((bits & 1) == 0)
      offset += n - nextn;
    n = nextn;
  }
  return offset + nextInt((int) n);
}
origin: org.mule.glassfish.grizzly/grizzly-framework

/**
 * Returns a pseudorandom, uniformly distributed value
 * between 0 (inclusive) and the specified value (exclusive).
 *
 * @param n the bound on the random number to be returned.  Must be
 *        positive.
 * @return the next value
 * @throws IllegalArgumentException if n is not positive
 */
public long nextLong(long n) {
  if (n <= 0)
    throw new IllegalArgumentException("n must be positive");
  // Divide n by two until small enough for nextInt. On each
  // iteration (at most 31 of them but usually much less),
  // randomly choose both whether to include high bit in result
  // (offset) and whether to continue with the lower vs upper
  // half (which makes a difference only if odd).
  long offset = 0;
  while (n >= Integer.MAX_VALUE) {
    int bits = next(2);
    long half = n >>> 1;
    long nextn = ((bits & 2) == 0) ? half : n - half;
    if ((bits & 1) == 0)
      offset += n - nextn;
    n = nextn;
  }
  return offset + nextInt((int) n);
}
origin: org.glassfish.grizzly/grizzly-http-server-core

/**
 * Returns a pseudorandom, uniformly distributed value
 * between 0 (inclusive) and the specified value (exclusive).
 *
 * @param n the bound on the random number to be returned.  Must be
 *        positive.
 * @return the next value
 * @throws IllegalArgumentException if n is not positive
 */
public long nextLong(long n) {
  if (n <= 0)
    throw new IllegalArgumentException("n must be positive");
  // Divide n by two until small enough for nextInt. On each
  // iteration (at most 31 of them but usually much less),
  // randomly choose both whether to include high bit in result
  // (offset) and whether to continue with the lower vs upper
  // half (which makes a difference only if odd).
  long offset = 0;
  while (n >= Integer.MAX_VALUE) {
    int bits = next(2);
    long half = n >>> 1;
    long nextn = ((bits & 2) == 0) ? half : n - half;
    if ((bits & 1) == 0)
      offset += n - nextn;
    n = nextn;
  }
  return offset + nextInt((int) n);
}
org.glassfish.grizzly.utilsThreadLocalRandomnext

Javadoc

Returns a pseudorandom, uniformly distributed double value between 0 (inclusive) and the specified value (exclusive).

Popular methods of ThreadLocalRandom

  • <init>
    Constructor called only by localRandom.initialValue.
  • nextDouble
    Returns a pseudorandom, uniformly distributed value between the given least value (inclusive) and bo
  • nextInt
    Returns a pseudorandom, uniformly distributed value between the given least value (inclusive) and bo
  • nextLong
    Returns a pseudorandom, uniformly distributed value between the given least value (inclusive) and bo
  • current
    Returns the current thread's ThreadLocalRandom.

Popular in Java

  • Making http post requests using okhttp
  • requestLocationUpdates (LocationManager)
  • runOnUiThread (Activity)
  • notifyDataSetChanged (ArrayAdapter)
  • Kernel (java.awt.image)
  • URL (java.net)
    A Uniform Resource Locator that identifies the location of an Internet resource as specified by RFC
  • Timestamp (java.sql)
    A Java representation of the SQL TIMESTAMP type. It provides the capability of representing the SQL
  • Iterator (java.util)
    An iterator over a sequence of objects, such as a collection.If a collection has been changed since
  • TreeMap (java.util)
    Walk the nodes of the tree left-to-right or right-to-left. Note that in descending iterations, next
  • ReentrantLock (java.util.concurrent.locks)
    A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now