Example usage for java.lang Thread setDaemon

List of usage examples for java.lang Thread setDaemon

Introduction

In this page you can find the example usage for java.lang Thread setDaemon.

Prototype

public final void setDaemon(boolean on) 

Source Link

Document

Marks this thread as either a #isDaemon daemon thread or a user thread.

Usage

From source file:Main.java

public static Thread runAsThread(Runnable runnable, boolean daemon) {
    Thread thread = new Thread(runnable);
    thread.setDaemon(daemon);
    thread.start();/*from  www . ja  v  a  2 s. c  om*/
    return thread;
}

From source file:Main.java

public static Thread spawn(Runnable runnable) {

    final Thread thread = new Thread(runnable);
    thread.setDaemon(false);
    thread.start();/*w  w w  .ja v a 2  s .  co  m*/

    return thread;
}

From source file:Main.java

public static void start(Runnable executer, String threadName, boolean demon) {
    Thread thread = new Thread(executer, threadName);
    thread.setDaemon(demon);
    thread.start();/*from   www . ja v a 2 s  . c  om*/
}

From source file:Main.java

public static final Thread doTask(Runnable runnable) {
    Thread t = new Thread(runnable);
    t.setDaemon(true);
    t.start();/*w  ww.ja v  a  2s. co  m*/
    return t;
}

From source file:Main.java

public static Thread runAsync(Runnable runnable, String threadName, boolean daemon) {
    Thread thread = new Thread(runnable, threadName);
    thread.setDaemon(daemon);
    thread.start();//from  ww  w.  j a  va 2 s .  co m
    return thread;
}

From source file:Main.java

public static void runAsDaemon(Runnable runnable) {
    Thread thread = new Thread(runnable);
    thread.setDaemon(true);
    thread.start();//from   w w w. ja  v  a 2 s  .  c  o m
}

From source file:Main.java

public static void runLater(final Runnable r) {
    Thread t = new Thread(r, "ThreadUtils.runLater-Thread");
    t.setDaemon(true);
    t.start();//from   www.ja v  a 2 s .  c om
}

From source file:Main.java

/**
 * Starts the given {@link Runnable} tasks as daemons
 * /*from w  w  w  .  j a  v  a 2 s . co  m*/
 * @param tasks
 */
public static void startDaemon(Runnable... tasks) {
    for (Runnable task : tasks) {
        Thread thread = new Thread(task);
        thread.setDaemon(true);
        thread.setPriority(Thread.NORM_PRIORITY);
        thread.start();
    }
}

From source file:Main.java

static ThreadFactory threadFactory(final String name, final boolean daemon) {
    return new ThreadFactory() {
        @Override//w w  w  .j a va 2 s . com
        public Thread newThread(Runnable runnable) {
            Thread result = new Thread(runnable, name);
            result.setDaemon(daemon);
            return result;
        }
    };
}

From source file:Main.java

public static ThreadFactory threadFactory(final String name, final boolean daemon) {
    return new ThreadFactory() {
        @Override//  ww  w  .j  av  a  2 s .c  om
        public Thread newThread(Runnable runnable) {
            Thread result = new Thread(runnable, name);
            result.setDaemon(daemon);
            return result;
        }
    };
}