Package java.util.concurrent

Examples of java.util.concurrent.CountDownLatch.await()


         else
         {
            executor.executeBlocking(wrapper, startTimeout, TimeUnit.MILLISECONDS);
         }

         startedLatch.await();

         return System.currentTimeMillis() - started;
      }
      catch (ExecutionTimedOutException etoe)
      {
View Full Code Here


         threadPool.execute(loaders[i]);
      }
     
      startingGun.countDown();
     
      assertTrue("loaders completed on time", finishedSignal.await(45, TimeUnit.SECONDS));    
     
      for (int i = 0; i < loaders.length; i++)
      {        
         assertNotNull("got checked attributes for " + i, loaders[i].checkedAttributes);
         assertTrue("checked 'count' attribute for " + i, loaders[i].checkedAttributes.containsKey("count"));
View Full Code Here

    KeyboardFocusManager.getCurrentKeyboardFocusManager().
        addPropertyChangeListener("activeWindow", activeWindowListener);
    // Check that a simple short task is correctly executed with no exception
    // and doesn't create any visible dialog at screen
    new ThreadedTaskController(shortTask, "Message", noExceptionHandler, preferences, viewFactory).executeTask(null);
    shortTaskLatch.await(1000, TimeUnit.MILLISECONDS);
    assertEquals("Simple task wasn't executed", 0, shortTaskLatch.getCount());
    KeyboardFocusManager.getCurrentKeyboardFocusManager().
        removePropertyChangeListener("activeWindow", activeWindowListener);
   
    // 2. Create a longer task
View Full Code Here

        };
    KeyboardFocusManager.getCurrentKeyboardFocusManager().
        addPropertyChangeListener("activeWindow", activeWindowListener);
    // Check that a long task creates a visible dialog at screen
    new ThreadedTaskController(longTask, "Message", noExceptionHandler, preferences, viewFactory).executeTask(null);
    longTaskLatch.await(1500, TimeUnit.MILLISECONDS);
    assertEquals("Long task wasn't executed with a waiting dialog", 0, longTaskLatch.getCount());
    KeyboardFocusManager.getCurrentKeyboardFocusManager().
        removePropertyChangeListener("activeWindow", activeWindowListener);
   
    // 3. Create a long task that we will cancel 
View Full Code Here

        };
    KeyboardFocusManager.getCurrentKeyboardFocusManager().
        addPropertyChangeListener("activeWindow", activeWindowListener);
    // Check that a long task creates a visible dialog at screen
    new ThreadedTaskController(cancelledTask, "Message", noExceptionHandler, preferences, viewFactory).executeTask(null);
    cancelledTaskLatch.await(1500, TimeUnit.MILLISECONDS);
    assertEquals("Task wasn't cancelled", 0, cancelledTaskLatch.getCount());
    KeyboardFocusManager.getCurrentKeyboardFocusManager().
        removePropertyChangeListener("activeWindow", activeWindowListener);

    // 4. Create a task that fails 
View Full Code Here

            failingTaskLatch.countDown();
          }
        };
    // Check that a long task creates a visible dialog at screen
    new ThreadedTaskController(failingTask, "Message", exceptionHandler, preferences, viewFactory).executeTask(null);
    failingTaskLatch.await(1000, TimeUnit.MILLISECONDS);
    assertEquals("Exception in task wasn't handled", 0, failingTaskLatch.getCount());
  }
}
View Full Code Here

      offScreenCanvas.renderOffScreenBuffer();
      offScreenCanvas.waitForOffScreenRendering();
     
      // If latch count becomes equal to 0 during the past instructions or in the coming 10 milliseconds,
      // this means that a rendering error happened
      if (latch.await(10, TimeUnit.MILLISECONDS)) {
        throw new IllegalRenderingStateException("Off screen rendering unavailable");
      }
     
      return offScreenCanvas.getOffScreenBuffer().getImage();
    } catch (InterruptedException ex) {
View Full Code Here

        }

        try {
            // Google App Engine doesn't allow a thread to block more than 30 seconds
            if (action.timeout != -1 && action.timeout < 30000) {
                latch.await(action.timeout, TimeUnit.MILLISECONDS);
            }
            else {
                latch.await(20000, TimeUnit.MILLISECONDS);
            }
        }
View Full Code Here

            // Google App Engine doesn't allow a thread to block more than 30 seconds
            if (action.timeout != -1 && action.timeout < 30000) {
                latch.await(action.timeout, TimeUnit.MILLISECONDS);
            }
            else {
                latch.await(20000, TimeUnit.MILLISECONDS);
            }
        }
        catch (Throwable ex) {
            logger.warn("Unable to resume the suspended connection", ex);
        }
View Full Code Here

            req.getSession().setAttribute(String.valueOf(req.hashCode()), hash);
        }

        try {
            if (action.timeout != -1) {
                latch.await(action.timeout, TimeUnit.MILLISECONDS);
            } else {
                latch.await();
            }
        } catch (InterruptedException ex) {
            logger.debug("", ex);
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.