Package jsr166y

Examples of jsr166y.Phaser


    taskExecutor.setAsyncMode(false);
    // Indicate to the task executor to maintain parallelism
    taskExecutor.setMaintainsParallelism(true);

    /* Create a Phaser */
    Phaser phaser = new Phaser(alphabet.length());

    /* Create tasks */
    List<FileCounterRecursiveTaskWithPhaser> tasks = new ArrayList<FileCounterRecursiveTaskWithPhaser>(alphabet.length());
    for (char c : alphabet.toCharArray()) {
      tasks.add(new FileCounterRecursiveTaskWithPhaser(new File(c + ":\\"), phaser));
    }

    /* Launch tasks */
    for (FileCounterRecursiveTaskWithPhaser task : tasks) {
      taskExecutor.execute(task);
    }

    /*
     * Wait tasks termination using the Phaser and then display processing
     * state
     */
    // There only 1 phase in our sample (phase start from zero)
    phaser.awaitAdvance(0);

    /* Display tasks processing state */
    int i = 0;
    for (FileCounterRecursiveTaskWithPhaser task : tasks) {
      System.out.printf("  ** Task for drive [%s:\\] processing status **\n", alphabet.charAt(i));
View Full Code Here

TOP

Related Classes of jsr166y.Phaser

Copyright © 2018 www.massapicom. 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.