From 67405dde9ba213331dab1fc46cb18c485070fd5b Mon Sep 17 00:00:00 2001
From: matthew_swift <matthew_swift@localhost>
Date: Fri, 05 Jun 2009 09:04:50 +0000
Subject: [PATCH] svn merge -r5333:5417 https://opends.dev.java.net/svn/opends/branches/b2.0
---
opends/src/server/org/opends/server/api/DirectoryThread.java | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 50 insertions(+), 0 deletions(-)
diff --git a/opends/src/server/org/opends/server/api/DirectoryThread.java b/opends/src/server/org/opends/server/api/DirectoryThread.java
index c2d66aa..95aa832 100644
--- a/opends/src/server/org/opends/server/api/DirectoryThread.java
+++ b/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();
--
Gitblit v1.10.0