Ejemplo n.º 1
0
 public void run() {
   if (isDone()) return;
   try {
     task.run();
   } catch (Throwable t) {
     log.error(Util.getMessage("FailedExecutingTask") + task, t);
   } finally {
     done = true;
   }
 }
Ejemplo n.º 2
0
    public void run() {
      if (cancelled) {
        if (future != null) future.cancel(true);
        return;
      }

      try {
        task.run();
      } catch (Throwable t) {
        log.error(Util.getMessage("FailedRunningTask") + task, t);
      }
      if (!cancelled) doSchedule();
    }
Ejemplo n.º 3
0
  public void run() {
    final long base_time = System.currentTimeMillis();
    long next_time, sleep_time;
    long cnt = 0;

    while (running) {
      try {
        _run();
        next_time = base_time + (++cnt * tick_time);
        sleep_time = Math.max(0, next_time - System.currentTimeMillis());
        Util.sleep(sleep_time);
      } catch (Throwable t) {
        log.error(Util.getMessage("FailedExecutingTasksS"), t);
      }
    }
  }
Ejemplo n.º 4
0
 protected void _run() {
   lock.lock();
   try {
     wheel_position = (wheel_position + 1) % wheel_size;
     List<MyTask> list = wheel[wheel_position];
     if (list.isEmpty()) return;
     for (Iterator<MyTask> it = list.iterator(); it.hasNext(); ) {
       MyTask tmp = it.next();
       if (tmp.getAndDecrementRound() <= 0) {
         try {
           pool.execute(tmp);
         } catch (Throwable t) {
           log.error(Util.getMessage("FailureSubmittingTaskToThreadPool"), t);
         }
         it.remove();
       }
     }
   } finally {
     lock.unlock();
   }
 }