Exemplo n.º 1
0
  /** Thread's overridden run method. */
  public synchronized void run() {
    running = true;

    Log log = LogFactory.getLog(WorkerThread.class);
    log.debug("Worker thread (" + this.getName() + ") born");

    synchronized (stp) {
      stp.notify();
    }

    while (running) {
      if (assigned) {
        state = WORKERTHREAD_BLOCKED;
        task.prepare();
        state = WORKERTHREAD_BUSY;
        try {
          task.execute();
          task.tearDown();
        } catch (Exception e) {
          log.fatal("PANIC! Task " + task + " threw an excpetion!", e);
          System.exit(1);
        }

        synchronized (stp) {
          assigned = false;
          task = null;
          state = WORKERTHREAD_IDLE;
          stp.notify();
          this.notify(); // if some thread is blocked in stopRunning();
        }
      }
      try {
        wait();
      } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
      }
    }

    /* notify the thread pool that we died. */
    log.debug("Worker thread (" + this.getName() + ") dying");
  }
Exemplo n.º 2
0
 public SiteDAOImpl(StorageSPI storage, DBUtil dbUtil) {
   this.storage = storage;
   this.dbUtil = dbUtil;
   this.log = LogFactory.getLog(SiteDAOImpl.class);
 }