
package uk.co.wingpath.util;

/**
* Class for creating daemon threads with uncaught-exception handlers.
*/
public class WThread
{
    /**
    * Creates a daemon {@link Thread} with an {@link UncaughtExceptionHandler}.
    * The thread is not started (see {@link Thread#start}).
    * @param name thread name.
    * @param reporter for reporting uncaught exceptions.
    * @param runnable to be executed by the thread.
    */
    public static Thread create (String name, Reporter reporter,
        Runnable runnable)
    {
        Thread t = new Thread (runnable, name);
        t.setDaemon (true);
        t.setUncaughtExceptionHandler (new UncaughtExceptionHandler (reporter));
        return t;
    }
}

