Package java.util.concurrent

Examples of java.util.concurrent.ScheduledExecutorService.scheduleWithFixedDelay()


   @SuppressWarnings({ "rawtypes", "unchecked" })
   public void testMonitorAndContinueWithoutTimeout() {
      ScheduledFuture mockFuture = EasyMock.createMock(ScheduledFuture.class);
      ScheduledExecutorService schedulerMock = EasyMock.createMock(ScheduledExecutorService.class);
      expect(
            schedulerMock.scheduleWithFixedDelay(anyObject(Runnable.class), anyLong(), anyLong(),
                  anyObject(TimeUnit.class))).andReturn(mockFuture);

      replay(mockFuture);
      replay(schedulerMock);
View Full Code Here


      ScheduledFuture mockFuture = EasyMock.createMock(ScheduledFuture.class);
      expect(mockFuture.isCancelled()).andReturn(true);

      ScheduledExecutorService schedulerMock = EasyMock.createMock(ScheduledExecutorService.class);
      expect(
            schedulerMock.scheduleWithFixedDelay(anyObject(Runnable.class), anyLong(), anyLong(),
                  anyObject(TimeUnit.class))).andReturn(mockFuture);

      replay(mockFuture);
      replay(schedulerMock);
View Full Code Here

      settings.setAliasEnabled(false);
      console = new Console();
      context.setOutputAdapter(new ConsoleIOAdapter(console));
      console.addCompletion(new Completer(context));
      ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
      sessionPingTask = executor.scheduleWithFixedDelay(new PingTask(), SESSION_PING_TIMEOUT, SESSION_PING_TIMEOUT, TimeUnit.SECONDS);

      while (!context.isQuitting()) {
         try {
            context.refreshProperties();
            String line = console.read(getPrompt()).getBuffer();
View Full Code Here

                Thread t = new Thread(runable, "OwbConversationCleaner-" + servletContext.getContextPath());
                t.setDaemon(true);
                return t;
            }
        });
        executorService.scheduleWithFixedDelay(new ConversationCleaner(context), delay, delay, TimeUnit.MILLISECONDS);

        ELAdaptor elAdaptor = context.getService(ELAdaptor.class);
        ELResolver resolver = elAdaptor.getOwbELResolver();
        //Application is configured as JSP
        if (context.getOpenWebBeansConfiguration().isJspApplication()) {
View Full Code Here

      /** Startup a scheduled executor service to look through the logs
       */
      ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
      BSStatusCollector statusCollector = new BSStatusCollector();
      ScheduledFuture<?> handle = scheduler.scheduleWithFixedDelay(statusCollector,
          0, 10, TimeUnit.SECONDS);
      LOG.info("Kicking off the scheduler for polling on logs in " +
          this.requestIdDir);
      try {

View Full Code Here

    /**
     * Schedules a background task for flushing the index once per second.
     */
    private void scheduleFlushTask() {
        ScheduledExecutorService executor = handler.getContext().getExecutor();
        flushTask = executor.scheduleWithFixedDelay(new Runnable() {
            public void run() {
                // check if there are any indexing jobs finished
                checkIndexingQueue(false);
                // check if volatile index should be flushed
                checkFlush();
View Full Code Here

     * @throws Exception if an error occurs
     */
    @Test
    public void testConcurrentGC() throws Exception {
        ScheduledExecutorService gcExecutor = Executors.newScheduledThreadPool(1);
        gcExecutor.scheduleWithFixedDelay(new Runnable() {
            @Override
            public void run() {
                rs.gc();
            }
        }, 100, 20, TimeUnit.MILLISECONDS);
View Full Code Here

     * @throws Exception if an error occurs
     */
    @Test
    public void testConcurrentMergeGC() throws Exception {
        ScheduledExecutorService gcExecutor = Executors.newScheduledThreadPool(1);
        gcExecutor.scheduleWithFixedDelay(new Runnable() {
            @Override
            public void run() {
                rs.gc();
            }
        }, 100, 20, TimeUnit.MILLISECONDS);
View Full Code Here

        throw new IllegalStateException();
      }
      ConcurrentLinkedHashMap<K, V> map = new ConcurrentLinkedHashMap<K, V>(this);
      if (executor != DEFAULT_EXECUTOR) {
        ScheduledExecutorService es = (ScheduledExecutorService) executor;
        es.scheduleWithFixedDelay(new CatchUpTask(map), delay, delay, unit);
      }
      return map;
    }
  }
}
View Full Code Here

  public ScheduledFuture scheduleWithFixedDelay(Runnable task, Date startTime, long delay) {
    ScheduledExecutorService executor = getScheduledExecutor();
    long initialDelay = startTime.getTime() - System.currentTimeMillis();
    try {
      return executor.scheduleWithFixedDelay(errorHandlingTask(task, true), initialDelay, delay, TimeUnit.MILLISECONDS);
    }
    catch (RejectedExecutionException ex) {
      throw new TaskRejectedException("Executor [" + executor + "] did not accept task: " + task, 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.