Package java.util.concurrent

Examples of java.util.concurrent.ThreadLocalRandom.nextInt()


                       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


               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(
View Full Code Here

                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

            log.info("Running metrics queries");

            ThreadLocalRandom random = ThreadLocalRandom.current();
            int bound = startingSchedule + batchSize;

            findResourceDataForPast24Hours(random.nextInt(startingSchedule, bound));
            findResourceDataForPastWeek(random.nextInt(startingSchedule, bound));
            findResourceDataForPast2Weeks(random.nextInt(startingSchedule, bound));
            findResourceDataForPast31Days(random.nextInt(startingSchedule, bound));
            findResourceDataForPastYear(random.nextInt(startingSchedule, bound));
        } finally {
View Full Code Here

            ThreadLocalRandom random = ThreadLocalRandom.current();
            int bound = startingSchedule + batchSize;

            findResourceDataForPast24Hours(random.nextInt(startingSchedule, bound));
            findResourceDataForPastWeek(random.nextInt(startingSchedule, bound));
            findResourceDataForPast2Weeks(random.nextInt(startingSchedule, bound));
            findResourceDataForPast31Days(random.nextInt(startingSchedule, bound));
            findResourceDataForPastYear(random.nextInt(startingSchedule, bound));
        } finally {
            stopwatch.stop();
View Full Code Here

            ThreadLocalRandom random = ThreadLocalRandom.current();
            int bound = startingSchedule + batchSize;

            findResourceDataForPast24Hours(random.nextInt(startingSchedule, bound));
            findResourceDataForPastWeek(random.nextInt(startingSchedule, bound));
            findResourceDataForPast2Weeks(random.nextInt(startingSchedule, bound));
            findResourceDataForPast31Days(random.nextInt(startingSchedule, bound));
            findResourceDataForPastYear(random.nextInt(startingSchedule, bound));
        } finally {
            stopwatch.stop();
            log.info("Finished running metrics queries in " + stopwatch.elapsed(TimeUnit.MILLISECONDS) + " ms");
View Full Code Here

            int bound = startingSchedule + batchSize;

            findResourceDataForPast24Hours(random.nextInt(startingSchedule, bound));
            findResourceDataForPastWeek(random.nextInt(startingSchedule, bound));
            findResourceDataForPast2Weeks(random.nextInt(startingSchedule, bound));
            findResourceDataForPast31Days(random.nextInt(startingSchedule, bound));
            findResourceDataForPastYear(random.nextInt(startingSchedule, bound));
        } finally {
            stopwatch.stop();
            log.info("Finished running metrics queries in " + stopwatch.elapsed(TimeUnit.MILLISECONDS) + " ms");
            context.stop();
View Full Code Here

            findResourceDataForPast24Hours(random.nextInt(startingSchedule, bound));
            findResourceDataForPastWeek(random.nextInt(startingSchedule, bound));
            findResourceDataForPast2Weeks(random.nextInt(startingSchedule, bound));
            findResourceDataForPast31Days(random.nextInt(startingSchedule, bound));
            findResourceDataForPastYear(random.nextInt(startingSchedule, bound));
        } finally {
            stopwatch.stop();
            log.info("Finished running metrics queries in " + stopwatch.elapsed(TimeUnit.MILLISECONDS) + " ms");
            context.stop();
        }
View Full Code Here

        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

            while (byteCount < trg.length)
            {
                byte[] nextRun;
                if (runCount == 0 || random.nextDouble() < this.randomRatio)
                {
                    nextRun = new byte[random.nextInt(randomRunLength[0], randomRunLength[1])];
                    random.nextBytes(nextRun );
                    runs[runCount % runs.length] = nextRun;
                    runCount++;
                }
                else
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.