code: public void joinThread(long timeout)
      {
          // take local ref copy, so can reliably check if ref is null,
          Thread local_thread_ref = thread;
          if (local_thread_ref != null)
          {
              try 
              {
                  long millis = 0l;
                  if (log.isDebugEnabled())
                  {
                      log.debug("BackgroundProcess.joinThread() Waiting " + timeout + " millis for " + this + " to finish");
                      millis = System.currentTimeMillis();
                  }
                  if (thread_pool != null)
                  {
                      synchronized (pool_mutex)
                      {
                          pool_mutex.wait(timeout);
                      }
                  }
                  else
                      local_thread_ref.join(timeout);
  
                  if (log.isDebugEnabled())
                  {
                      millis = System.currentTimeMillis() - millis;
                      log.debug("BackgroundProcess.joinThread() Process " + this + " finished in " + millis + " millis");
                  }
              } 
              catch (InterruptedException e) 
              {
                  if (log.isDebugEnabled())
                      log.debug("BackgroundProcess.joinThread() Timed out waiting " + timeout + " millis for " + this + " to finish");
              }
          }
          else
          {
              if (log.isDebugEnabled())
                  log.debug("BackgroundProcess.joinThread() " + name + " was not running, thread was null");
          }
      }
docs: Inactivively waits for the process to finish or until timeout occurs,
  whichever is earlier. If the process was not running, returns immediatelly.
  
  @param timeout