Example usage for java.util.concurrent CountDownLatch await

List of usage examples for java.util.concurrent CountDownLatch await

Introduction

In this page you can find the example usage for java.util.concurrent CountDownLatch await.

Prototype

public void await() throws InterruptedException 

Source Link

Document

Causes the current thread to wait until the latch has counted down to zero, unless the thread is Thread#interrupt interrupted .

Usage

From source file:org.apache.geode.geospatial.grid.SpringBootGeodeServer.java

public static void main(String[] args) throws InterruptedException {
    SpringApplication.run(SpringBootGeodeServer.class);
    CountDownLatch countDownLatch = new CountDownLatch(1);
    countDownLatch.await();
}

From source file:com.dianping.dpsf.other.echo.EchoServer.java

/**
 * @param args/*from  ww w  . ja  va  2  s . co m*/
 * @throws InterruptedException 
 */
public static void main(String[] args) throws InterruptedException {
    Thread.currentThread().setName("=============EchoSerer1============");
    ApplicationContext ctx = new ClassPathXmlApplicationContext("echo-server.xml");
    if (args.length == 0) { //stand alone start
        CountDownLatch latch = new CountDownLatch(1);
        latch.await();
    }
}

From source file:com.dianping.dpsf.other.echo.EchoServer2.java

/**
 * @param args//from   w  w w. j a  v  a2s. c  o  m
 * @throws InterruptedException 
 */
public static void main(String[] args) throws InterruptedException {
    Thread.currentThread().setName("=============EchoSerer2============");
    ApplicationContext ctx = new ClassPathXmlApplicationContext("echo-server2.xml");
    if (args.length == 0) { //stand alone start
        CountDownLatch latch = new CountDownLatch(1);
        latch.await();
    }
}

From source file:com.dianping.dpsf.other.echo.EchoServer3.java

/**
 * @param args/*from  www .  j a  v a 2s  .c o m*/
 * @throws InterruptedException 
 */
public static void main(String[] args) throws InterruptedException {
    Thread.currentThread().setName("=============EchoSerer3============");
    ApplicationContext ctx = new ClassPathXmlApplicationContext("echo-server3.xml");
    if (args.length == 0) { //stand alone start
        CountDownLatch latch = new CountDownLatch(1);
        latch.await();
    }
}

From source file:com.dianping.dpsf.other.echo.EchoServer4.java

/**
 * @param args//from  w w  w. j a  v a 2 s. c  om
 * @throws InterruptedException 
 */
public static void main(String[] args) throws InterruptedException {
    Thread.currentThread().setName("=============EchoSerer4============");
    ApplicationContext ctx = new ClassPathXmlApplicationContext("echo-server4.xml");
    if (args.length == 0) { //stand alone start
        CountDownLatch latch = new CountDownLatch(1);
        latch.await();
    }
}

From source file:Main.java

public static void main(String args[]) {
    CountDownLatch cdl = new CountDownLatch(5);
    new MyThread(cdl);

    try {//from w  ww . j av  a  2 s  .  c o  m
        cdl.await();
    } catch (InterruptedException exc) {
        System.out.println(exc);
    }
    System.out.println("Done");
}

From source file:Main.java

public static void main(String args[]) {
    CountDownLatch cdl = new CountDownLatch(5);
    System.out.println(cdl.getCount());
    new MyThread(cdl);

    try {//  ww w .  java2  s.c o m
        cdl.await();
    } catch (InterruptedException exc) {
        System.out.println(exc);
    }
    System.out.println("Done");
}

From source file:Main.java

public static void main(String[] args) {
    CountDownLatch latch = new CountDownLatch(1);
    for (int threadNo = 0; threadNo < 1000; threadNo++) {
        Runnable t = new Test(latch);
        new Thread(t).start();
    }/*w  w w.j av a  2 s  .  c  o  m*/
    try {
        latch.await();
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    System.out.println("done");
}

From source file:bundestagswahl.benchmark.BWBenchmark.java

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

    resultTime = new double[6];

    Scanner scanner = new Scanner(System.in);
    System.out.print("Please enter URL: ");
    serverUrl = scanner.nextLine();/*from   ww w .  j  a  v  a  2s. co m*/
    System.out.print("Please enter number of terminals: ");
    numberTerminals = scanner.nextInt();
    System.out.print("Please enter number of requests: ");
    numberRequests = scanner.nextInt();
    System.out.print("Please enter delay between two requests in seconds: ");
    requestDelay = scanner.nextDouble();
    scanner.close();

    PoolingClientConnectionManager cm = new PoolingClientConnectionManager();
    cm.setMaxTotal(numberTerminals);
    HttpClient httpclient = new DefaultHttpClient(cm);
    httpclient.getParams().setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 300000)
            .setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 300000)
            .setIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, 8 * 1024)
            .setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, true);
    try {
        final CountDownLatch latch = new CountDownLatch(numberTerminals);
        for (int i = 0; i < numberTerminals; i++) {
            BenchmarkTerminal terminal = new BenchmarkTerminal(httpclient, latch, serverUrl, numberRequests,
                    requestDelay);
            terminal.start();
        }
        latch.await();
        httpclient.getConnectionManager().shutdown();
    } finally {

    }

    printResultTimes();
    System.out.println(" ");
    System.out.println("Done");
}

From source file:SimpExec.java

public static void main(String args[]) {
    CountDownLatch cdl = new CountDownLatch(5);
    CountDownLatch cdl2 = new CountDownLatch(5);
    CountDownLatch cdl3 = new CountDownLatch(5);
    CountDownLatch cdl4 = new CountDownLatch(5);
    ExecutorService es = Executors.newFixedThreadPool(2);

    es.execute(new MyThread(cdl, "A"));
    es.execute(new MyThread(cdl2, "B"));
    es.execute(new MyThread(cdl3, "C"));
    es.execute(new MyThread(cdl4, "D"));

    try {/*from   ww w.ja v  a2 s .c o  m*/
        cdl.await();
        cdl2.await();
        cdl3.await();
        cdl4.await();
    } catch (InterruptedException exc) {
        System.out.println(exc);
    }

    es.shutdown();
}