Examples of ThreadLocalRandom


Examples of ca.eandb.jmist.framework.random.ThreadLocalRandom

    this.background = background;
    this.rng = rng;
  }

  public SceneRayShader(SceneElement root, Light light, RayShader background) {
    this(root, light, background, new ThreadLocalRandom(new SimpleRandom()));
  }
View Full Code Here

Examples of ca.eandb.jmist.framework.random.ThreadLocalRandom

  public SceneRayShader(SceneElement root, Light light, RayShader background) {
    this(root, light, background, new ThreadLocalRandom(new SimpleRandom()));
  }

  public SceneRayShader(Scene scene, RayShader background) {
    this(scene.getRoot(), scene.getLight(), background, new ThreadLocalRandom(new SimpleRandom()));
  }
View Full Code Here

Examples of ca.eandb.jmist.framework.random.ThreadLocalRandom

  public SceneRayShader(Scene scene, RayShader background) {
    this(scene.getRoot(), scene.getLight(), background, new ThreadLocalRandom(new SimpleRandom()));
  }

  public SceneRayShader(Scene scene) {
    this(scene.getRoot(), scene.getLight(), RayShader.BLACK, new ThreadLocalRandom(new SimpleRandom()));
  }
View Full Code Here

Examples of com.firefly.utils.ThreadLocalRandom

     */
    private E awaitMatch(Node s, Node pred, E e, boolean timed, long nanos) {
        long lastTime = timed ? System.nanoTime() : 0L;
        Thread w = Thread.currentThread();
        int spins = -1; // initialized after first item and cancel checks
        ThreadLocalRandom randomYields = null; // bound if needed

        for (;;) {
            Object item = s.item;
            if (item != e) {                  // matched
                // assert item != s;
                s.forgetContents();           // avoid garbage
                return LinkedTransferQueue.<E>cast(item);
            }
            if ((w.isInterrupted() || (timed && nanos <= 0)) &&
                    s.casItem(e, s)) {        // cancel
                unsplice(pred, s);
                return e;
            }

            if (spins < 0) {                  // establish spins at/near front
                if ((spins = spinsFor(pred, s.isData)) > 0)
                    randomYields = ThreadLocalRandom.current();
            }
            else if (spins > 0) {             // spin
                --spins;
                if (randomYields.nextInt(CHAINED_SPINS) == 0)
                    Thread.yield();           // occasionally yield
            }
            else if (s.waiter == null) {
                s.waiter = w;                 // request unpark then recheck
            }
View Full Code Here

Examples of com.firefly.utils.ThreadLocalRandom

     */
    private E awaitMatch(Node s, Node pred, E e, boolean timed, long nanos) {
        long lastTime = timed ? System.nanoTime() : 0L;
        Thread w = Thread.currentThread();
        int spins = -1; // initialized after first item and cancel checks
        ThreadLocalRandom randomYields = null; // bound if needed

        for (;;) {
            Object item = s.item;
            if (item != e) {                  // matched
                // assert item != s;
                s.forgetContents();           // avoid garbage
                return LinkedTransferQueue.<E>cast(item);
            }
            if ((w.isInterrupted() || (timed && nanos <= 0)) &&
                    s.casItem(e, s)) {        // cancel
                unsplice(pred, s);
                return e;
            }

            if (spins < 0) {                  // establish spins at/near front
                if ((spins = spinsFor(pred, s.isData)) > 0)
                    randomYields = ThreadLocalRandom.current();
            }
            else if (spins > 0) {             // spin
                --spins;
                if (randomYields.nextInt(CHAINED_SPINS) == 0)
                    Thread.yield();           // occasionally yield
            }
            else if (s.waiter == null) {
                s.waiter = w;                 // request unpark then recheck
            }
View Full Code Here

Examples of java.util.concurrent.ThreadLocalRandom

    {
      public void writeData(Attributes attributes)
      {
        try
        {
          final ThreadLocalRandom random = ThreadLocalRandom.current();
          DataSource dataSource = WicketApplication.get().getDataSource();
          World[] worlds = new World[queries];
          try (Connection connection = dataSource.getConnection())
          {
            try (PreparedStatement statement = connection.prepareStatement(
                       "SELECT * FROM World WHERE id = ?",
                       ResultSet.TYPE_FORWARD_ONLY,
                       ResultSet.CONCUR_READ_ONLY))
            {
              for (int i = 0; i < queries; i++)
              {
                  statement.setInt(1, random.nextInt(DB_ROWS) + 1);
                  try (ResultSet resultSet = statement.executeQuery())
                  {
                      resultSet.next();
                      worlds[i] = new World(
                              resultSet.getInt("id"),
View Full Code Here

Examples of java.util.concurrent.ThreadLocalRandom

    response.setWriteCallback(new WriteCallback() {
      public void writeData(Attributes attributes)
      {
        try
        {
          final ThreadLocalRandom random = ThreadLocalRandom.current();
          DataSource dataSource = WicketApplication.get().getDataSource();

          World[] worlds = new World[queries];
          try (Connection connection = dataSource.getConnection();
               PreparedStatement query = connection.prepareStatement(
                       "SELECT * FROM World WHERE id = ?",
                       ResultSet.TYPE_FORWARD_ONLY,
                       ResultSet.CONCUR_READ_ONLY);
               PreparedStatement update = connection.prepareStatement(
                       "UPDATE World SET randomNumber = ? WHERE id= ?"))
          {
            for (int i = 0; i < queries; i++)
            {
              query.setInt(1, random.nextInt(DB_ROWS) + 1);
              World world;
              try (ResultSet resultSet = query.executeQuery())
              {
                resultSet.next();
                world = new World(
                    resultSet.getInt("id"),
                    resultSet.getInt("randomNumber"));
              }
              world.randomNumber = random.nextInt(DB_ROWS) + 1;
              update.setInt(1, world.randomNumber);
              update.setInt(2, world.id);
              update.executeUpdate();
              worlds[i] = world;
            }
View Full Code Here

Examples of java.util.concurrent.ThreadLocalRandom

    }

    private Set<MeasurementDataNumeric> generateData() {
        Set<MeasurementDataNumeric> data = new HashSet<MeasurementDataNumeric>(batchSize);
        long timestamp = dateTimeService.nowInMillis();
        ThreadLocalRandom random = ThreadLocalRandom.current();

        for (int i = 0; i < batchSize; ++i) {
            data.add(new MeasurementDataNumeric(timestamp, startingScheduleId + i, random.nextDouble()));
        }

        return data;
    }
View Full Code Here

Examples of java.util.concurrent.ThreadLocalRandom

      Collection<Example> examples = input.first();
      FeedforwardParams params = input.second();

      // We can't fix the seed used with ThreadLocalRandom
      // TODO: Is this a serious problem?
      ThreadLocalRandom random = ThreadLocalRandom.current();

      gradW1 = new double[W1.length][W1[0].length];
      gradb1 = new double[b1.length];
      gradW2 = new double[W2.length][W2[0].length];
      gradE = new double[E.length][E[0].length];

      double cost = 0.0;
      double correct = 0.0;

      for (Example ex : examples) {
        List<Integer> feature = ex.getFeature();
        List<Integer> label = ex.getLabel();

        double[] scores = new double[numLabels];
        double[] hidden = new double[config.hiddenSize];
        double[] hidden3 = new double[config.hiddenSize];

        // Run dropout: randomly drop some hidden-layer units. `ls`
        // contains the indices of those units which are still active
        int[] ls = IntStream.range(0, config.hiddenSize)
                            .filter(n -> random.nextDouble() > params.getDropOutProb())
                            .toArray();

        int offset = 0;
        for (int j = 0; j < config.numTokens; ++j) {
          int tok = feature.get(j);
View Full Code Here

Examples of java.util.concurrent.ThreadLocalRandom

        final ScheduledExecutorService sched;

        TestOrdering(ExecutorService exec, ScheduledExecutorService sched)
        {
            this.sched = sched;
            final ThreadLocalRandom rnd = ThreadLocalRandom.current();
            for (int i = 0 ; i < waitNanos.length ; i++)
                waitNanos[i] = rnd.nextInt(5000);
            for (int i = 0 ; i < PRODUCERS / CONSUMERS ; i++)
                exec.execute(new Producer());
            exec.execute(this);
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.