mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

matthew_swift
05.04.2009 9dc10dec2d5d7f61116f7f647b7cf9596ca77be0
opendj-sdk/opends/src/server/org/opends/server/api/DirectoryThread.java
@@ -30,6 +30,8 @@
import java.util.Map;
import java.util.LinkedHashMap;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicInteger;
import org.opends.server.backends.task.Task;
import org.opends.server.core.DirectoryServer;
@@ -77,6 +79,54 @@
       extends Thread
{
  /**
   * A factory which can be used by thread pool based services such as
   * {@code Executor}s to dynamically create new
   * {@code DirectoryThread} instances.
   */
  public static final class Factory implements ThreadFactory
  {
    // The name prefix used for all threads created using this
    // factory.
    private final String threadNamePrefix;
    // The ID to use for the next thread created using this factory.
    private final AtomicInteger nextID = new AtomicInteger();
    /**
     * Creates a new directory thread factory using the provided
     * thread name prefix.
     *
     * @param threadNamePrefix
     *          The name prefix used for all threads created using
     *          this factory.
     */
    public Factory(String threadNamePrefix)
    {
      if (threadNamePrefix == null) {
        throw new NullPointerException("Null thread name prefix");
      }
      this.threadNamePrefix = threadNamePrefix;
    }
    /**
     * {@inheritDoc}
     */
    public Thread newThread(Runnable r)
    {
      return new DirectoryThread(r, threadNamePrefix + " "
          + nextID.getAndIncrement());
    }
  }
  /**
   * The tracer object for the debug logger.
   */
  private static final DebugTracer TRACER = getTracer();