Exemplo n.º 1
0
  // @Override
  protected void doSetUp() throws Exception {
    super.doSetUp();

    // allow 1 active & 1 queued Thread
    executor =
        new ThreadPoolExecutor(1, 1, 10000L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue(1));
    executor.prestartAllCoreThreads();

    // the lock must be fair to guarantee FIFO access to the executor;
    // 'synchronized' on a monitor is not good enough.
    executorLock = new ReentrantLock(true);

    // this is a Threadgroup that collects uncaught exceptions. Necessary for JDK
    // 1.4.x only.
    threadGroup = new ExceptionCollectingThreadGroup();

    // reset counter of active SleepyTasks
    SleepyTask.activeTasks.set(0);
  }