HADOOP-7166. Add DaemonFactory to common. Contributed by Erik Steffl and jitendra.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1080775 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jitendra Nath Pandey 2011-03-11 21:57:21 +00:00
parent 96da4be11c
commit 05704fe46e
2 changed files with 18 additions and 0 deletions

View File

@ -74,6 +74,8 @@ Trunk (unreleased changes)
HADOOP-7133. Batch the calls in DataStorage to FileUtil.createHardLink(). HADOOP-7133. Batch the calls in DataStorage to FileUtil.createHardLink().
(Matt Foley via jghoman) (Matt Foley via jghoman)
HADOOP-7166. Add DaemonFactory to common. (Erik Steffl & jitendra)
OPTIMIZATIONS OPTIMIZATIONS
BUG FIXES BUG FIXES

View File

@ -18,6 +18,8 @@
package org.apache.hadoop.util; package org.apache.hadoop.util;
import java.util.concurrent.ThreadFactory;
import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability; import org.apache.hadoop.classification.InterfaceStability;
@ -30,6 +32,20 @@ public class Daemon extends Thread {
setDaemon(true); // always a daemon setDaemon(true); // always a daemon
} }
/**
* Provide a factory for named daemon threads,
* for use in ExecutorServices constructors
*/
@InterfaceAudience.LimitedPrivate({"HDFS", "MapReduce"})
public static class DaemonFactory extends Daemon implements ThreadFactory {
@Override
public Thread newThread(Runnable runnable) {
return new Daemon(runnable);
}
}
Runnable runnable = null; Runnable runnable = null;
/** Construct a daemon thread. */ /** Construct a daemon thread. */
public Daemon() { public Daemon() {