Example usage for java.lang Thread sleep

List of usage examples for java.lang Thread sleep

Introduction

In this page you can find the example usage for java.lang Thread sleep.

Prototype

public static native void sleep(long millis) throws InterruptedException;

Source Link

Document

Causes the currently executing thread to sleep (temporarily cease execution) for the specified number of milliseconds, subject to the precision and accuracy of system timers and schedulers.

Usage

From source file:com.bt.aloha.batchtest.WeekendBatchTest.java

public static void main(String[] args) throws Exception {
    ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("batchTestApplicationContext.xml");
    BatchTest batchTest = (BatchTest) ctx.getBean("batchTestBean");
    batchTest.setApplicationContext(ctx);
    batchTest.init();//from w  w  w.  ja v  a2s  .co  m
    batchTest.assignNewCollectionsToBeans();

    while (true) {
        configure(batchTest);
        if (stop)
            break;
        batchTest.run();
        logStatistics(log, batchTest);
        batchTest.reset();
        if (sleepTime > 0) {
            log.info(String.format("sleeping for %d minutes", sleepTime / 60 / 1000));
            Thread.sleep(sleepTime);
        }
    }
    // wait until all things in collection should be ready for housekeeping
    Properties batchProps = new Properties();
    InputStream is = batchTest.getClass().getResourceAsStream("/batchrun.sip.properties");
    batchProps.load(is);
    is.close();
    Thread.sleep(Long.parseLong(batchProps.getProperty("dialog.max.time.to.live", "900000"))
            + Long.parseLong(batchProps.getProperty("housekeeping.interval", "300000")));
    // housekeeping should have happend
    // log out all things still left
    logCollections(batchTest);

    batchTest.destroy();
}

From source file:com.linkedin.pinotdruidbenchmark.PinotThroughput.java

@SuppressWarnings("InfiniteLoopStatement")
public static void main(String[] args) throws Exception {
    if (args.length != 3 && args.length != 4) {
        System.err.println(// w w  w.  j a  va 2s  .  c  o  m
                "3 or 4 arguments required: QUERY_DIR, RESOURCE_URL, NUM_CLIENTS, TEST_TIME (seconds).");
        return;
    }

    File queryDir = new File(args[0]);
    String resourceUrl = args[1];
    final int numClients = Integer.parseInt(args[2]);
    final long endTime;
    if (args.length == 3) {
        endTime = Long.MAX_VALUE;
    } else {
        endTime = System.currentTimeMillis() + Integer.parseInt(args[3]) * MILLIS_PER_SECOND;
    }

    File[] queryFiles = queryDir.listFiles();
    assert queryFiles != null;
    Arrays.sort(queryFiles);

    final int numQueries = queryFiles.length;
    final HttpPost[] httpPosts = new HttpPost[numQueries];
    for (int i = 0; i < numQueries; i++) {
        HttpPost httpPost = new HttpPost(resourceUrl);
        String query = new BufferedReader(new FileReader(queryFiles[i])).readLine();
        httpPost.setEntity(new StringEntity("{\"pql\":\"" + query + "\"}"));
        httpPosts[i] = httpPost;
    }

    final AtomicInteger counter = new AtomicInteger(0);
    final AtomicLong totalResponseTime = new AtomicLong(0L);
    final ExecutorService executorService = Executors.newFixedThreadPool(numClients);

    for (int i = 0; i < numClients; i++) {
        executorService.submit(new Runnable() {
            @Override
            public void run() {
                try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
                    while (System.currentTimeMillis() < endTime) {
                        long startTime = System.currentTimeMillis();
                        CloseableHttpResponse httpResponse = httpClient
                                .execute(httpPosts[RANDOM.nextInt(numQueries)]);
                        httpResponse.close();
                        long responseTime = System.currentTimeMillis() - startTime;
                        counter.getAndIncrement();
                        totalResponseTime.getAndAdd(responseTime);
                    }
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        });
    }
    executorService.shutdown();

    long startTime = System.currentTimeMillis();
    while (System.currentTimeMillis() < endTime) {
        Thread.sleep(REPORT_INTERVAL_MILLIS);
        double timePassedSeconds = ((double) (System.currentTimeMillis() - startTime)) / MILLIS_PER_SECOND;
        int count = counter.get();
        double avgResponseTime = ((double) totalResponseTime.get()) / count;
        System.out.println("Time Passed: " + timePassedSeconds + "s, Query Executed: " + count + ", QPS: "
                + count / timePassedSeconds + ", Avg Response Time: " + avgResponseTime + "ms");
    }
}

From source file:eu.interedition.collatex.http.Server.java

public static void main(String... args) {
    try {/*from  w w w .  j  av  a 2s  .  com*/
        final CommandLine commandLine = new GnuParser().parse(OPTIONS, args);
        if (commandLine.hasOption("h")) {
            new HelpFormatter().printHelp("collatex-server [<options> ...]\n", OPTIONS);
            return;
        }

        final Collator collator = new Collator(Integer.parseInt(commandLine.getOptionValue("mpc", "2")),
                Integer.parseInt(commandLine.getOptionValue("mcs", "0")),
                commandLine.getOptionValue("dot", null));
        final String staticPath = System.getProperty("collatex.static.path", "");
        final HttpHandler httpHandler = staticPath.isEmpty()
                ? new CLStaticHttpHandler(Server.class.getClassLoader(), "/static/") {
                    @Override
                    protected void onMissingResource(Request request, Response response) throws Exception {
                        collator.service(request, response);
                    }
                }
                : new StaticHttpHandler(staticPath.replaceAll("/+$", "") + "/") {
                    @Override
                    protected void onMissingResource(Request request, Response response) throws Exception {
                        collator.service(request, response);
                    }
                };

        final NetworkListener httpListener = new NetworkListener("http", "0.0.0.0",
                Integer.parseInt(commandLine.getOptionValue("p", "7369")));

        final CompressionConfig compressionConfig = httpListener.getCompressionConfig();
        compressionConfig.setCompressionMode(CompressionConfig.CompressionMode.ON);
        compressionConfig.setCompressionMinSize(860); // http://webmasters.stackexchange.com/questions/31750/what-is-recommended-minimum-object-size-for-gzip-performance-benefits
        compressionConfig.setCompressableMimeTypes("application/javascript", "application/json",
                "application/xml", "text/css", "text/html", "text/javascript", "text/plain", "text/xml");

        final HttpServer httpServer = new HttpServer();
        httpServer.addListener(httpListener);
        httpServer.getServerConfiguration().addHttpHandler(httpHandler,
                commandLine.getOptionValue("cp", "").replaceAll("/+$", "") + "/*");

        Runtime.getRuntime().addShutdownHook(new Thread(() -> {
            if (LOG.isLoggable(Level.INFO)) {
                LOG.info("Stopping HTTP server");
            }
            httpServer.shutdown();
        }));

        httpServer.start();

        Thread.sleep(Long.MAX_VALUE);
    } catch (Throwable t) {
        LOG.log(Level.SEVERE, "Error while parsing command line", t);
        System.exit(1);
    }
}

From source file:com.omertron.slackbot.SlackBot.java

public static void main(String[] args) throws Exception {
    LOG.info("Starting {} v{} ...", Constants.BOT_NAME, Constants.BOT_VERSION);

    // Load the properties
    PropertiesUtil.setPropertiesStreamName(DEFAULT_PROPERTIES_FILE);

    LOG.info("Starting session...");
    SlackSession session;/*  ww w .j  ava 2 s .co m*/

    String proxyURL = PropertiesUtil.getProperty(Constants.PROXY_HOST);
    if (StringUtils.isNotBlank(proxyURL)) {
        int proxyPort = Integer.parseInt(PropertiesUtil.getProperty(Constants.PROXY_PORT, "80"));
        session = SlackSessionFactory.getSlackSessionBuilder(Constants.BOT_TOKEN)
                .withProxy(Proxy.Type.HTTP, proxyURL, proxyPort).build();
    } else {
        session = SlackSessionFactory
                .createWebSocketSlackSession(PropertiesUtil.getProperty(Constants.BOT_TOKEN));
    }

    session.connect();

    // Populate the BOT admins
    populateBotAdmins(session);

    // Notify BOT admins
    notifyStartup(session);

    // Add the listeners to the session
    addListeners(session);

    LOG.info("Session connected: {}", session.isConnected());
    LOG.info("\tConnected to {} ({})", session.getTeam().getName(), session.getTeam().getId());
    LOG.info("\tFound {} channels and {} users", session.getChannels().size(), session.getUsers().size());

    outputBotAdminsMessage();

    LOG.info("Starting the Task Executor");
    executor = new BotTaskExecutor(session);

    LOG.info("Checking for users welcomed list");
    BotWelcome.readFile();

    LOG.info("Checking for stats file");
    BotStatistics.readFile();
    LOG.info("Stats read:\n{}", BotStatistics.generateStatistics(false, true));

    Thread.sleep(Long.MAX_VALUE);
}

From source file:mcnutty.music.get.MusicGet.java

public static void main(String[] args) throws Exception {

    //print out music-get
    System.out.println("                     _                      _   ");
    System.out.println(" _ __ ___  _   _ ___(_) ___       __ _  ___| |_ ");
    System.out.println("| '_ ` _ \\| | | / __| |/ __|____ / _` |/ _ \\ __|");
    System.out.println("| | | | | | |_| \\__ \\ | (_|_____| (_| |  __/ |_ ");
    System.out.println("|_| |_| |_|\\__,_|___/_|\\___|     \\__, |\\___|\\__|");
    System.out.println("                                 |___/          \n");

    //these will always be initialised later (but the compiler doesn't know that)
    String directory = "";
    Properties prop = new Properties();

    try (InputStream input = new FileInputStream("config.properties")) {
        prop.load(input);/*from w w  w . ja  v a 2 s . c o m*/
        if (prop.getProperty("directory") != null) {
            directory = prop.getProperty("directory");
        } else {
            System.out.println(
                    "Error reading config property 'directory' - using default value of /tmp/musicserver/\n");
            directory = "/tmp/musicserver/";
        }
        if (prop.getProperty("password") == null) {
            System.out.println("Error reading config property 'password' - no default value, exiting\n");
            System.exit(1);
        }
    } catch (IOException e) {
        System.out.println("Error reading config file");
        System.exit(1);
    }

    //create a queue object
    ProcessQueue process_queue = new ProcessQueue();

    try {
        if (args.length > 0 && args[0].equals("clean")) {
            Files.delete(Paths.get("queue.json"));
        }
        //load an existing queue if possible
        String raw_queue = Files.readAllLines(Paths.get("queue.json")).toString();
        JSONArray queue_state = new JSONArray(raw_queue);
        ConcurrentLinkedQueue<QueueItem> loaded_queue = new ConcurrentLinkedQueue<>();
        JSONArray queue = queue_state.getJSONArray(0);
        for (int i = 0; i < queue.length(); i++) {
            JSONObject item = ((JSONObject) queue.get(i));
            QueueItem loaded_item = new QueueItem();
            loaded_item.ip = item.getString("ip");
            loaded_item.real_name = item.getString("name");
            loaded_item.disk_name = item.getString("guid");
            loaded_queue.add(loaded_item);
        }
        process_queue.bucket_queue = loaded_queue;
        System.out.println("Loaded queue from disk\n");
    } catch (Exception ex) {
        //otherwise clean out the music directory and start a new queue
        try {
            Files.walkFileTree(Paths.get(directory), new SimpleFileVisitor<Path>() {
                @Override
                public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
                    Files.delete(file);
                    return FileVisitResult.CONTINUE;
                }
            });
            Files.delete(Paths.get(directory));
        } catch (Exception e) {
            e.printStackTrace();
        }
        Files.createDirectory(Paths.get(directory));
        System.out.println("Created a new queue\n");
    }

    //start the web server
    StartServer start_server = new StartServer(process_queue, directory);
    new Thread(start_server).start();

    //wit for the web server to spool up
    Thread.sleep(1000);

    //read items from the queue and play them
    while (true) {
        QueueItem next_item = process_queue.next_item();
        if (!next_item.equals(new QueueItem())) {
            //Check the timeout
            int timeout = 547;
            try (FileInputStream input = new FileInputStream("config.properties")) {
                prop.load(input);
                timeout = Integer.parseInt(prop.getProperty("timeout", "547"));
            } catch (Exception e) {
                e.printStackTrace();
            }
            System.out.println("Playing " + next_item.real_name);
            process_queue.set_played(next_item);
            process_queue.save_queue();
            Process p = Runtime.getRuntime().exec("timeout " + timeout
                    + "s mplayer -fs -quiet -af volnorm=2:0.25 " + directory + next_item.disk_name);

            try {
                p.waitFor(timeout, TimeUnit.SECONDS);
                Files.delete(Paths.get(directory + next_item.disk_name));
            } catch (Exception e) {
                e.printStackTrace();
            }
        } else {
            process_queue.bucket_played.clear();
        }
        Thread.sleep(1000);
    }
}

From source file:DruidThroughput.java

@SuppressWarnings("InfiniteLoopStatement")
public static void main(String[] args) throws Exception {
    final int numQueries = QUERIES.length;
    final Random random = new Random(RANDOM_SEED);
    final AtomicInteger counter = new AtomicInteger(0);
    final AtomicLong totalResponseTime = new AtomicLong(0L);
    final ExecutorService executorService = Executors.newFixedThreadPool(NUM_CLIENTS);

    for (int i = 0; i < NUM_CLIENTS; i++) {
        executorService.submit(new Runnable() {
            @Override/*from   w ww.ja v  a  2 s.  co m*/
            public void run() {
                try (CloseableHttpClient client = HttpClients.createDefault()) {
                    HttpPost post = new HttpPost("http://localhost:8082/druid/v2/?pretty");
                    post.addHeader("content-type", "application/json");
                    CloseableHttpResponse res;
                    while (true) {
                        try (BufferedReader reader = new BufferedReader(new FileReader(
                                QUERY_FILE_DIR + File.separator + random.nextInt(numQueries) + ".json"))) {
                            int length = reader.read(BUFFER);
                            post.setEntity(new StringEntity(new String(BUFFER, 0, length)));
                        }
                        long start = System.currentTimeMillis();
                        res = client.execute(post);
                        res.close();
                        counter.getAndIncrement();
                        totalResponseTime.getAndAdd(System.currentTimeMillis() - start);
                    }
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        });
    }

    long startTime = System.currentTimeMillis();
    while (true) {
        Thread.sleep(REPORT_INTERVAL_MILLIS);
        double timePassedSeconds = ((double) (System.currentTimeMillis() - startTime)) / MILLIS_PER_SECOND;
        int count = counter.get();
        double avgResponseTime = ((double) totalResponseTime.get()) / count;
        System.out.println("Time Passed: " + timePassedSeconds + "s, Query Executed: " + count + ", QPS: "
                + count / timePassedSeconds + ", Avg Response Time: " + avgResponseTime + "ms");
    }
}

From source file:neembuu.uploader.versioning.CheckUser.java

public static void main(String[] args) throws Exception {
    UserImpl.init(Application.getUserId());
    for (int i = 0; i < 10000; i++) {
        getCanCustomizeNormalizing(new UserSetPriv() {

            @Override//w ww.j ava  2  s  .  c  om
            public void setCanCustomizeNormalizing(boolean canCustomizeNormalizing) {
                System.out.println("canCustomize = " + canCustomizeNormalizing);
            }

            @Override
            public void setNormalization(String normalization) {
                System.out.println("nomalization = " + normalization);
            }
        });
        Thread.sleep(1000);
    }
}

From source file:org.wso2.carbon.sample.pizzadelivery.client.PizzaDeliveryClient.java

public static void main(String[] args) {

    KeyStoreUtil.setTrustStoreParams();/*from   w  w w .j  a v a2 s.  c o m*/
    String url = args[0];
    String username = args[1];
    String password = args[2];

    HttpClient httpClient = new SystemDefaultHttpClient();

    try {
        HttpPost method = new HttpPost(url);

        if (httpClient != null) {
            String[] xmlElements = new String[] {
                    "<mypizza:PizzaDeliveryStream xmlns:mypizza=\"http://samples.wso2.org/\">\n"
                            + "        <mypizza:PizzaDelivery>\n"
                            + "              <mypizza:OrderNo>0023</mypizza:OrderNo>\n"
                            + "              <mypizza:PaymentType>Card</mypizza:PaymentType>\n"
                            + "              <mypizza:Address>29BX Finchwood Ave, Clovis, CA 93611</mypizza:Address>\n"
                            + "        </mypizza:PizzaDelivery>\n" + "</mypizza:PizzaDeliveryStream>",
                    "<mypizza:PizzaDeliveryStream xmlns:mypizza=\"http://samples.wso2.org/\">\n"
                            + "        <mypizza:PizzaDelivery>\n"
                            + "              <mypizza:OrderNo>0024</mypizza:OrderNo>\n"
                            + "              <mypizza:PaymentType>Card</mypizza:PaymentType>\n"
                            + "              <mypizza:Address>2CYL Morris Ave, Clovis, CA 93611</mypizza:Address>\n"
                            + "        </mypizza:PizzaDelivery>\n" + "</mypizza:PizzaDeliveryStream>",
                    "<mypizza:PizzaDeliveryStream xmlns:mypizza=\"http://samples.wso2.org/\">\n"
                            + "        <mypizza:PizzaDelivery>\n"
                            + "              <mypizza:OrderNo>0025</mypizza:OrderNo>\n"
                            + "              <mypizza:PaymentType>Cash</mypizza:PaymentType>\n"
                            + "              <mypizza:Address>22RE Robinwood Ave, Clovis, CA 93611</mypizza:Address>\n"
                            + "        </mypizza:PizzaDelivery>\n" + "</mypizza:PizzaDeliveryStream>",
                    "<mypizza:PizzaDeliveryStream xmlns:mypizza=\"http://samples.wso2.org/\">\n"
                            + "        <mypizza:PizzaDelivery>\n"
                            + "              <mypizza:OrderNo>0026</mypizza:OrderNo>\n"
                            + "              <mypizza:PaymentType>Card</mypizza:PaymentType>\n"
                            + "              <mypizza:Address>29BX Finchwood Ave, Clovis, CA 93611</mypizza:Address>\n"
                            + "        </mypizza:PizzaDelivery>\n" + "</mypizza:PizzaDeliveryStream>" };

            try {
                for (String xmlElement : xmlElements) {
                    StringEntity entity = new StringEntity(xmlElement);
                    method.setEntity(entity);
                    if (url.startsWith("https")) {
                        processAuthentication(method, username, password);
                    }
                    httpClient.execute(method).getEntity().getContent().close();
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
            Thread.sleep(500); // We need to wait some time for the message to be sent

        }
    } catch (Throwable t) {
        t.printStackTrace();
    }
}

From source file:bluevia.examples.MODemo.java

/**
 * @param args//from www  .j  a va  2 s.com
 */
public static void main(String[] args) throws IOException {

    BufferedReader iReader = null;
    String apiDataFile = "API-AccessToken.ini";

    String consumer_key;
    String consumer_secret;
    String registrationId;

    OAuthConsumer apiConsumer = null;
    HttpURLConnection request = null;
    URL moAPIurl = null;

    Logger logger = Logger.getLogger("moSMSDemo.class");
    int i = 0;
    int rc = 0;

    Thread mThread = Thread.currentThread();

    try {
        System.setProperty("debug", "1");

        iReader = new BufferedReader(new FileReader(apiDataFile));

        // Private data: consumer info + access token info + phone info
        consumer_key = iReader.readLine();
        consumer_secret = iReader.readLine();
        registrationId = iReader.readLine();

        // Set up the oAuthConsumer
        while (true) {
            try {

                logger.log(Level.INFO, String.format("#%d: %s\n", ++i, "Requesting messages..."));

                apiConsumer = new DefaultOAuthConsumer(consumer_key, consumer_secret);

                apiConsumer.setMessageSigner(new HmacSha1MessageSigner());

                moAPIurl = new URL("https://api.bluevia.com/services/REST/SMS/inbound/" + registrationId
                        + "/messages?version=v1&alt=json");

                request = (HttpURLConnection) moAPIurl.openConnection();
                request.setRequestMethod("GET");

                apiConsumer.sign(request);

                StringBuffer doc = new StringBuffer();
                BufferedReader br = null;

                rc = request.getResponseCode();
                if (rc == HttpURLConnection.HTTP_OK) {
                    br = new BufferedReader(new InputStreamReader(request.getInputStream()));

                    String line = br.readLine();
                    while (line != null) {
                        doc.append(line);
                        line = br.readLine();
                    }

                    System.out.printf("Output message: %s\n", doc.toString());
                    try {
                        JSONObject apiResponse1 = new JSONObject(doc.toString());
                        String aux = apiResponse1.getString("receivedSMS");
                        if (aux != null) {
                            String szMessage;
                            String szOrigin;
                            String szDate;

                            JSONObject smsPool = apiResponse1.getJSONObject("receivedSMS");
                            JSONArray smsInfo = smsPool.optJSONArray("receivedSMS");
                            if (smsInfo != null) {
                                for (i = 0; i < smsInfo.length(); i++) {
                                    szMessage = smsInfo.getJSONObject(i).getString("message");
                                    szOrigin = smsInfo.getJSONObject(i).getJSONObject("originAddress")
                                            .getString("phoneNumber");
                                    szDate = smsInfo.getJSONObject(i).getString("dateTime");
                                    System.out.printf("#%d %s\n - from %s\n - message:%s\n", i, szDate,
                                            szOrigin, szMessage);
                                }
                            } else {
                                JSONObject sms = smsPool.getJSONObject("receivedSMS");
                                szMessage = sms.getString("message");
                                szOrigin = sms.getJSONObject("originAddress").getString("phoneNumber");
                                szDate = sms.getString("dateTime");
                                System.out.printf("#%d %s\n - from %s\n - message:%s\n", i, szDate, szOrigin,
                                        szMessage);
                            }
                        }
                    } catch (JSONException e) {
                        System.err.println("JSON error: " + e.getMessage());
                    }

                } else if (rc == HttpURLConnection.HTTP_NO_CONTENT)
                    System.out.printf("No content\n");
                else
                    System.err.printf("Error: %d:%s\n", rc, request.getResponseMessage());

                request.disconnect();

            } catch (Exception e) {
                System.err.println("Exception: " + e.getMessage());
            }
            mThread.sleep(15000);
        }
    } catch (Exception e) {
        System.err.println("Exception: " + e.getMessage());
    }
}

From source file:com.ciphertool.zodiacengine.CipherSolutionEngine.java

/**
 * @param args//  ww w  .java  2s  .co m
 * @throws InterruptedException
 */
public static void main(String[] args) throws InterruptedException {
    // Spin up the Spring application context
    setUp();

    CipherDto cipherDto = null;
    Runnable cipherTask = null;
    Thread cipherWorker = null;
    long threadIterations = 0;
    Cipher cipher = cipherDao.findByCipherName(cipherName);

    long start = System.currentTimeMillis();

    List<Thread> threads = new ArrayList<Thread>();
    List<CipherDto> cipherDtos = new ArrayList<CipherDto>();

    if (maxThreads > numIterations) {
        log.warn("The number of threads is greater than the number of tasks.  Reducing thread count to "
                + numIterations + ".");

        maxThreads = (int) numIterations;
    }

    log.info("Beginning solution generation.  Generating " + numIterations + " solutions using " + maxThreads
            + " threads.");

    for (int i = 1; i <= maxThreads; i++) {
        threadIterations = (numIterations / maxThreads);
        if (i == 1) {
            /*
             * If the number of iterations doesn't divide evenly among the
             * threads, add the remainder to the first thread
             */
            threadIterations += (numIterations % maxThreads);
        }

        cipherDto = new CipherDto(String.valueOf(i), cipher);
        cipherDtos.add(cipherDto);

        cipherTask = new CipherSolutionRunnable(threadIterations, solutionGenerator, solutionEvaluator,
                cipherDto);

        cipherWorker = new Thread(cipherTask, String.valueOf(i));

        cipherWorker.start();
        threads.add(cipherWorker);
    }

    /*
     * Keep checking threads until no more are left running
     */
    int running = 0;
    do {
        running = 0;
        for (Thread thread : threads) {
            if (thread.isAlive()) {
                running++;
            }
        }

        /*
         * There's no need to loop through this as fast as possible. Sleep
         * for a short period so that there isn't so much overhead from
         * monitoring the threads' state.
         */
        Thread.sleep(monitorSleepMillis);
    } while (running > 0);

    long totalSolutions = 0;
    long totalMatchSum = 0;
    long uniqueMatchSum = 0;
    long adjacentMatchSum = 0;

    BigInteger cipherId = cipher.getId();
    int rows = cipher.getRows();
    int columns = cipher.getColumns();
    SolutionChromosome solutionMostMatches = new SolutionChromosome(cipherId, 0, 0, 0, rows, columns);
    SolutionChromosome solutionMostUnique = new SolutionChromosome(cipherId, 0, 0, 0, rows, columns);
    SolutionChromosome solutionMostAdjacent = new SolutionChromosome(cipherId, 0, 0, 0, rows, columns);

    /*
     * Sum up all data from all CipherDtos passed to the threads
     */
    for (CipherDto nextCipherDto : cipherDtos) {
        log.debug("Best solution from thread " + nextCipherDto.getThreadName() + ": "
                + nextCipherDto.getSolutionMostMatches());
        log.debug("Most unique solution from thread " + nextCipherDto.getThreadName() + ": "
                + nextCipherDto.getSolutionMostUnique());
        log.debug("Solution with most adjacent matches from thread " + nextCipherDto.getThreadName() + ": "
                + nextCipherDto.getSolutionMostAdjacent());

        totalSolutions += nextCipherDto.getNumSolutions();
        totalMatchSum += nextCipherDto.getTotalMatchSum();
        uniqueMatchSum += nextCipherDto.getUniqueMatchSum();
        adjacentMatchSum += nextCipherDto.getAdjacentMatchSum();

        /*
         * Find the Solution with the highest number of total matches
         */
        if (nextCipherDto.getSolutionMostMatches().getTotalMatches() > solutionMostMatches.getTotalMatches()) {
            solutionMostMatches = nextCipherDto.getSolutionMostMatches();
        }

        /*
         * Find the Solution with the highest number of unique matches in
         * plaintext
         */
        if (nextCipherDto.getSolutionMostUnique().getUniqueMatches() > solutionMostUnique.getUniqueMatches()) {
            solutionMostUnique = nextCipherDto.getSolutionMostUnique();
        }

        /*
         * Find the Solution with the highest number of adjacent matches in
         * plaintext
         */
        if (nextCipherDto.getSolutionMostAdjacent().getAdjacentMatchCount() > solutionMostAdjacent
                .getAdjacentMatchCount()) {
            solutionMostAdjacent = nextCipherDto.getSolutionMostAdjacent();
        }
    }

    /*
     * Print out summary information
     */
    log.info("Took " + (System.currentTimeMillis() - start) + "ms to generate and validate " + totalSolutions
            + " solutions.");
    log.info("Most total matches achieved: " + solutionMostMatches.getTotalMatches());
    log.info("Average total matches: " + (totalMatchSum / totalSolutions));
    log.info("Best solution found: " + solutionMostMatches);
    log.info("Most unique matches achieved: " + solutionMostUnique.getUniqueMatches());
    log.info("Average unique matches: " + (uniqueMatchSum / totalSolutions));
    log.info("Solution with most unique matches found: " + solutionMostUnique);
    log.info("Most adjacent matches achieved: " + solutionMostAdjacent.getAdjacentMatchCount());
    log.info("Average adjacent matches: " + (adjacentMatchSum / totalSolutions));
    log.info("Solution with most adjacent matches found: " + solutionMostAdjacent);
}