code: public static void runAndWait(final Runnable r) {
          try {
              if (r != null) {
                  final Thread thread = new Thread(r);
                  thread.start();
                  thread.join();
              }
          } catch (final Exception ex) {
              LOG.debug("Thread has been interrupted and cannot be joined", ex);
          }
      }
docs: Provides the boilerplate code for running and waiting on a Runnable.