code: public static InstrumentedThreadFactory privilegedThreadFactory(MetricRegistry registry, String name) {
          return new InstrumentedThreadFactory(Executors.privilegedThreadFactory(), registry, name);
      }
docs: Returns an instrumented thread factory used to create new threads that
  have the same permissions as the current thread.
  <p>
  This factory creates threads with the same settings as {@link
  Executors#defaultThreadFactory}, additionally setting the
  AccessControlContext and contextClassLoader of new threads to
  be the same as the thread invoking this
  {@code privilegedThreadFactory} method.  A new
  {@code privilegedThreadFactory} can be created within an
  {@link java.security.AccessController#doPrivileged AccessController.doPrivileged}
  action setting the current thread's access control context to
  create threads with the selected permission settings holding
  within that action.
  </p>
  <p>Note that while tasks running within such threads will have
  the same access control and class loader settings as the
  current thread, they need not have the same {@link
  java.lang.ThreadLocal} or {@link
  java.lang.InheritableThreadLocal} values. If necessary,
  particular values of thread locals can be set or reset before
  any task runs in {@link ThreadPoolExecutor} subclasses using
  {@link ThreadPoolExecutor#beforeExecute(Thread, Runnable)}.
  Also, if it is necessary to initialize worker threads to have
  the same InheritableThreadLocal settings as some other
  designated thread, you can create a custom ThreadFactory in
  which that thread waits for and services requests to create
  others that will inherit its values.
  
  @param registry the {@link MetricRegistry} that will contain the metrics.
  @param name     the (metrics) name for this executor service, see {@link MetricRegistry#name(String, String...)}.
  @return a thread factory
  @throws java.security.AccessControlException if the current access control
  context does not have permission to both get and set context
  class loader
  @see Executors#privilegedThreadFactory()