From: Bryan T. <tho...@us...> - 2007-02-21 20:17:34
|
Update of /cvsroot/cweb/bigdata/src/java/com/bigdata/util/concurrent In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv5461/src/java/com/bigdata/util/concurrent Added Files: DaemonThreadFactory.java Log Message: Further work supporting transactional isolation. --- NEW FILE: DaemonThreadFactory.java --- package com.bigdata.util.concurrent; import java.util.concurrent.Executors; import java.util.concurrent.ThreadFactory; /** * A thread factory that configures the thread as a daemon thread. * * @author <a href="mailto:tho...@us...">Bryan Thompson</a> * @version $Id$ */ public class DaemonThreadFactory implements ThreadFactory { final private ThreadFactory delegate; private static ThreadFactory _default = new DaemonThreadFactory(); /** * Returns an instance based on {@link Executors#defaultThreadFactory()} * that configures the thread for daemon mode. */ final public static ThreadFactory defaultThreadFactory() { return _default; } /** * Uses {@link Executors#defaultThreadFactory()} as the delegate. */ public DaemonThreadFactory() { this( Executors.defaultThreadFactory() ); } /** * Uses the specified delegate {@link ThreadFactory}. * * @param delegate * The delegate thread factory that is responsible for * creating the threads. */ public DaemonThreadFactory(ThreadFactory delegate) { assert delegate != null; this.delegate = delegate; } public Thread newThread(Runnable r) { Thread t = delegate.newThread( r ); t.setDaemon(true); // System.err.println("new thread: "+t.getName()); return t; } } |