Examples of Phaser


Examples of co.paralleluniverse.strands.concurrent.Phaser

        this.N = Integer.parseInt(props.getProperty("N", "10000"));
        this.speedVariance = Double.parseDouble(props.getProperty("speed-variance", "1"));
        this.range = Double.parseDouble(props.getProperty("radar-range", "10"));
        this.extrapolate = Boolean.parseBoolean(props.getProperty("extrapolate", "true"));

        this.phaser = Boolean.parseBoolean(props.getProperty("phaser", "false")) ? new Phaser() : null;

        if (props.getProperty("dir") != null) // collect performance metrics in csv files
            createMetricsFiles(props);

        println("Galaxy node: " + (glxNode > 0 ? glxNode : " NOT DISTRIBUTED"));
View Full Code Here

Examples of hj.lang.phaser

        }
       
        if (isFirstSingle>0) {
            Iterator<phaser> it = singlePhasers.iterator();
            while (it.hasNext()) {
                phaser ph = it.next();
                ph.holdSingle(this);
            }
        }
       
        return isFirstSingle;
    }
View Full Code Here

Examples of hj.lang.phaser

    public void unregisterAllPhasers(Activity owner) {
        lock.lock();
        try {
            Iterator<phaser> iter= phasers.iterator();
            while (iter.hasNext()) {
                phaser ph = iter.next();
                ph.unregisterSignaler(owner);
                ph.unregisterWaiter(owner);
            }
        } finally {
            lock.unlock();
        }
    }
View Full Code Here

Examples of java.util.concurrent.Phaser

  /**
   * @param args
   */
  public static void main(String[] args) {
    byte threadNumber = 2;
    Phaser phaser = new Phaser();
    for (byte i = 1; i <= threadNumber; i++)
      new Thread(new PhasedTask(phaser, i)).start();
   
  }
View Full Code Here

Examples of java.util.concurrent.Phaser

   * @param args
   */
  public static void main(String[] args) {
   
    // Creates a Phaser with three participants
    Phaser phaser=new Phaser(3);
   
    // Creates 3 FileSearch objects. Each of them search in different directory
    FileSearch system=new FileSearch("C:\\Windows", "log", phaser);
    FileSearch apps=new FileSearch("C:\\Program Files","log",phaser);
    FileSearch documents=new FileSearch("C:\\Documents And Settings","log",phaser);
   
    // Creates a thread to run the system FileSearch and starts it
    Thread systemThread=new Thread(system,"System");
    systemThread.start();
   
    // Creates a thread to run the apps FileSearch and starts it
    Thread appsThread=new Thread(apps,"Apps");
    appsThread.start();
   
    // Creates a thread to run the documents  FileSearch and starts it
    Thread documentsThread=new Thread(documents,"Documents");
    documentsThread.start();
    try {
      systemThread.join();
      appsThread.join();
      documentsThread.join();
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
   
    System.out.printf("Terminated: %s\n",phaser.isTerminated());

  }
View Full Code Here

Examples of java.util.concurrent.Phaser

   */
  public static void main(String[] args) throws Exception {
    /*
     * Create a new Phaser for three participants
     */
    Phaser phaser=new Phaser(3);
   
    /*
     * Create and launch three tasks
     */
    for (int i=0; i<3; i++) {
      Task task=new Task(i+1, phaser);
      Thread thread=new Thread(task);
      thread.start();
    }
   
    /*
     * Write information about the Phaser
     */
    for (int i=0; i<10; i++) {
      System.out.printf("********************\n");
      System.out.printf("Main: Phaser Log\n");
      System.out.printf("Main: Phaser: Phase: %d\n",phaser.getPhase());
      System.out.printf("Main: Phaser: Registered Parties: %d\n",phaser.getRegisteredParties());
      System.out.printf("Main: Phaser: Arrived Parties: %d\n",phaser.getArrivedParties());
      System.out.printf("Main: Phaser: Unarrived Parties: %d\n",phaser.getUnarrivedParties());
      System.out.printf("********************\n");

      TimeUnit.SECONDS.sleep(1);
    }
  }
 
View Full Code Here

Examples of java.util.concurrent.Phaser

   */
  @Test
  public void illegalStateClearBlocked1() throws ParserException {
    initAvoidance();
    // we do not use the Byteman integration    
    final Phaser a = new pt.ul.jarmus.ext.Phaser(1);
    final Phaser b = new pt.ul.jarmus.ext.Phaser(1);
    JArmus.register(a);
    JArmus.register(b);
    b.arriveAndAwaitAdvance();
    a.arriveAndAwaitAdvance();
  }
View Full Code Here

Examples of java.util.concurrent.Phaser

   */
  @Test
  public void illegalStateClearBlocked2() throws ParserException {
    initAvoidance();
       
    final Phaser a = new Phaser(1);
    final Phaser b = new Phaser(1);
    JArmus.register(a);
    JArmus.register(b);
    b.arriveAndAwaitAdvance();
    a.arriveAndAwaitAdvance();
  }
View Full Code Here

Examples of java.util.concurrent.Phaser

   */
  @Test
  public void falseDeadlock1a() {
    initAvoidance();
       
    final Phaser a = new pt.ul.jarmus.ext.Phaser(1);
    final Phaser b = new pt.ul.jarmus.ext.Phaser(1);
    JArmus.register(a);
    JArmus.register(b);
    b.arrive();
    a.arriveAndAwaitAdvance();
    b.awaitAdvance(0);
  }
View Full Code Here

Examples of java.util.concurrent.Phaser

   */
  @Test
  public void falseDeadlock1b() throws InterruptedException, InstantiationException, IllegalAccessException {
    initAvoidance();
       
    final Phaser a = new Phaser(1);
    final Phaser b = new Phaser(1);
    JArmus.register(a);
    JArmus.register(b);
    b.arrive();
    a.arriveAndAwaitAdvance();
    b.awaitAdvance(0);
  }
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.