src/main/java/org/jboss/util/threadpool/BasicTaskWrapper.java
public void run()
   {
      // Get the execution thread
      this.runThread = Thread.currentThread();

      // Check for a start timeout
      long runTime = getElapsedTime();
      if (startTimeout > 0l && runTime >= startTimeout)
      {
         taskRejected(new StartTimeoutException("Start Timeout exceeded for task " + taskString));
         return;
      }

      // We are about to start, check for a stop
      boolean stopped = false;
      synchronized (stateLock)
      {
         if (state == TASK_STOPPED)
         {
            stopped = true;
         }
         else
         {
            state = TASK_STARTED;
            taskStarted();
            if (waitType == Task.WAIT_FOR_START)
               stateLock.notifyAll();
         }
      }
      if (stopped)
      {
         taskRejected(new TaskStoppedException("Task stopped for task " + taskString));
         return;
      }

      // Run the task
      Throwable throwable = null;
      try
      {
         task.execute();
      }
      catch (Throwable t)
      {
         throwable = t;
      }

      // It is complete
      taskCompleted(throwable);

      // We are completed
      synchronized (stateLock)
      {
         state = TASK_COMPLETED;
         if (waitType == Task.WAIT_FOR_COMPLETE)
            stateLock.notifyAll();
      }
   }
public void run()
   {
      // Get the execution thread
      this.runThread = Thread.currentThread();

      // Check for a start timeout
      long runTime = getElapsedTime();
      if (startTimeout > 0l && runTime >= startTimeout)
      {
         taskRejected(new StartTimeoutException("Start Timeout exceeded for task " + taskString));
         return;
      }

      // We are about to start, check for a stop
      boolean stopped = false;
      synchronized (stateLock)
      {
         if (state == TASK_STOPPED)
         {
            stopped = true;
         }
         else
         {
            state = TASK_STARTED;
            taskStarted();
            if (waitType == Task.WAIT_FOR_START)
               stateLock.notifyAll();
         }
      }
      if (stopped)
      {
         taskRejected(new TaskStoppedException("Task stopped for task " + taskString));
         return;
      }

      // Run the task
      Throwable throwable = null;
      try
      {
         task.execute();
      }
      catch (Throwable t)
      {
         throwable = t;
      }

      // It is complete
      taskCompleted(throwable);

      // We are completed
      synchronized (stateLock)
      {
         state = TASK_COMPLETED;
         if (waitType == Task.WAIT_FOR_COMPLETE)
            stateLock.notifyAll();
      }
   }
public void run ( ) { // Get the execution thread this . runThread = Thread . currentThread ( ) ; // Check for a start timeout long runTime = getElapsedTime ( ) ; if ( startTimeout > 0l && runTime >= startTimeout ) { taskRejected ( new StartTimeoutException ( "Start Timeout exceeded for task " + taskString ) ) ; return ; } // We are about to start, check for a stop boolean stopped = false ; synchronized ( stateLock ) { if ( state == TASK_STOPPED ) { stopped = true ; } else { state = TASK_STARTED ; taskStarted ( ) ; if ( waitType == Task . WAIT_FOR_START ) stateLock . notifyAll ( ) ; } } if ( stopped ) { taskRejected ( new TaskStoppedException ( "Task stopped for task " + taskString ) ) ; return ; } // Run the task Throwable throwable = null ; try { task . execute ( ) ; } catch ( Throwable t ) { throwable = t ; } // It is complete taskCompleted ( throwable ) ; // We are completed synchronized ( stateLock ) { state = TASK_COMPLETED ; if ( waitType == Task . WAIT_FOR_COMPLETE ) stateLock . notifyAll ( ) ; } }
Called by the thread pool executor
Called by the thread pool executor