Examples of CountDownLatch


Examples of java.util.concurrent.CountDownLatch

      conflict.setUniqueName(SIMPLE_TRIMMED_PATH);
      modsmd.add(conflict);
     
      ExecutorService executor = Executors.newFixedThreadPool(3);
     
      CountDownLatch startLatch = new CountDownLatch(4);
      CountDownLatch finishLatch = new CountDownLatch(3);
     
      DeploymentTask warTask = new DeploymentTask(startLatch, finishLatch, war);
      executor.execute(warTask);
     
      DeploymentTask jarTask = new DeploymentTask(startLatch, finishLatch, jar);
      executor.execute(jarTask);
     
      DeploymentTask appclientTask = new DeploymentTask(startLatch, finishLatch, appClient);
      executor.execute(appclientTask);
     
      startLatch.countDown();
     
      assertTrue(finishLatch.await(5, TimeUnit.SECONDS));
     
      assertNull(warTask.exception);
      assertNull(jarTask.exception);
      assertNull(appclientTask.exception);
     
View Full Code Here

Examples of java.util.concurrent.CountDownLatch

    * @throws Exception
    */
   public void testLifecycleWithLockedFile() throws Exception
   {
      String fileName = "jnp-service-" + count + ".url";
      tearDownLatch = new CountDownLatch(1);
      CountDownLatch lockedLatch = new CountDownLatch(1);
      FileLocker locker = new FileLocker(tempDir, fileName, null, tearDownLatch, lockedLatch);
     
      NamingProviderURLWriter testee = new NamingProviderURLWriter();
      testee.setOutputDirURL(tempDir);
      testee.setOutputFileName(fileName);
      testee.setBootstrapAddress("localhost");
      testee.setBootstrapPort(9999);
     
      Thread t = new Thread(locker);
      t.setDaemon(true);
      t.start();
      assertTrue("FileLocker locked file", lockedLatch.await(10, TimeUnit.SECONDS));
      testee.start();
      testee.stop();
   }
View Full Code Here

Examples of org.rhq.coregui.client.util.async.CountDownLatch

     */
    public void setMetricRangePreferences(MetricRangePreferences prefs, boolean allowRefresh, Command callback) {
        AsyncCallback<Subject> persistCallback = null;
        if (null != callback) {
            // there are either 2 or 3 setPreference calls depending on prefs.explicitBeginEnd
            final CountDownLatch latch = CountDownLatch.create(prefs.explicitBeginEnd ? 2 : 3, callback);
            persistCallback = new AsyncCallback<Subject>() {
                @Override
                public void onFailure(Throwable arg0) {
                    latch.countDown();
                }

                @Override
                public void onSuccess(Subject arg0) {
                    latch.countDown();
                }
            };
        }
        userPrefs.setPreference(PREF_METRIC_RANGE_BEGIN_END_FLAG, String.valueOf(prefs.explicitBeginEnd), allowRefresh, persistCallback);
        if (prefs.explicitBeginEnd) {
View Full Code Here

Examples of org.waveprotocol.wave.client.common.util.CountdownLatch

     */
    @Override
    protected void create(final Accessor<StageTwo> whenReady) {
      onStageInit();

      final CountdownLatch synchronizer = CountdownLatch.create(2, new Command() {
        @Override
        public void execute() {
          install();
          onStageLoaded();
          whenReady.use(DefaultProvider.this);
        }
      });

      fetchWave(new Accessor<WaveViewData>() {
        @Override
        public void use(WaveViewData x) {
          waveData = x;
          synchronizer.tick();
        }
      });

      // Defer everything else, to let the RPC go out.
      SchedulerInstance.getMediumPriorityTimer().scheduleDelayed(new Task() {
        @Override
        public void execute() {
          installStatics();
          synchronizer.tick();
        }
      }, 20);
    }
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.