public static void shutdown(final Thread t, final long joinwait) {
    if (t == null) return;
    while (t.isAlive()) {
      try {
        t.join(joinwait);
      } catch (InterruptedException e) {
        LOG.warn(t.getName() + "; joinwait=" + joinwait, e);
      }
    }
  }
Shutdown passed thread using isAlive and join.
@param joinwait Pass 0 if we're to wait forever.
@param t        Thread to shutdown
hbase-common/src/main/java/org/apache/hadoop/hbase/util/Threads.java