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:com.espertech.esper.core.thread.EngineThreadFactory.java

public Thread newThread(Runnable runnable) {
    String name = "com.espertech.esper." + prefix + "-" + engineURI + "-" + currThreadCount;
    currThreadCount++;//from ww w. j  a  v  a2s. com
    Thread t = new Thread(threadGroup, runnable, name);
    t.setDaemon(true);
    t.setPriority(threadPriority);

    if (log.isDebugEnabled()) {
        log.debug("Creating thread '" + name + "' : " + t + " priority " + threadPriority);
    }
    return t;
}

From source file:com.google.cloud.tools.maven.it.verifier.TailingVerifier.java

private void startTailingLog() {
    TailerListener listener = new TailerListenerAdapter() {
        @Override/*from  ww w  . j  a  va  2  s  .com*/
        public void handle(String line) {
            System.out.println(testName + ": " + line);
        }
    };

    // Tail the log
    File file = new File(getBasedir() + File.separator + getLogFileName());
    try {
        if (file.exists()) {
            file.delete();
        }
        file.createNewFile();
    } catch (IOException e) {
        e.printStackTrace();
    }
    Tailer tailer = new Tailer(file, listener, TAIL_DELAY_MILLIS);
    Thread thread = new Thread(tailer);
    thread.setDaemon(true);
    thread.start();
}

From source file:edu.syr.bytecast.util.StreamEater.java

public StreamEater(InputStream stream) {
    m_inputStream = stream;//www  .  j  av  a2s  .co  m
    m_done = false;
    m_print = false;
    Thread thread = new Thread(this);
    thread.setDaemon(true);
    thread.start();
}

From source file:edu.syr.bytecast.util.StreamEater.java

public StreamEater(InputStream stream, boolean print) {
    m_inputStream = stream;/*from   www  .j a va 2 s .com*/
    m_done = false;
    m_print = print;
    Thread thread = new Thread(this);
    thread.setDaemon(true);
    thread.start();
}

From source file:com.newlandframework.rpc.parallel.NamedThreadFactory.java

public Thread newThread(Runnable runnable) {
    String name = prefix + mThreadNum.getAndIncrement();
    Thread ret = new Thread(threadGroup, runnable, name, 0);
    ret.setDaemon(daemoThread);
    return ret;//from  w  w w  .  ja v a2  s. c om
}

From source file:Main.java

public static void executeWithProgressDialogInBackground(final Runnable runnable, final StackPane target,
        final String text) {
    Thread th = new Thread() {
        @Override/*from   w w  w  .  ja v a2  s .co m*/
        public void run() {
            final Node progressIndicator = createProgressIndicator();
            final Label label = new Label(text);
            try {
                Platform.runLater(new Runnable() {
                    @Override
                    public void run() {
                        target.getChildren().add(progressIndicator);
                        label.setWrapText(true);
                        target.getChildren().add(label);
                    }
                });
                runnable.run();
            } finally {
                Platform.runLater(new Runnable() {
                    @Override
                    public void run() {
                        target.getChildren().remove(progressIndicator);
                        target.getChildren().remove(label);
                    }
                });
            }
        }
    };
    th.setDaemon(true);
    th.start();
}

From source file:edu.umd.cs.buildServer.BuildServerDaemon.java

public static void timedSystemExit0() {
    Thread t = new Thread(new Runnable() {

        @Override//  w  w  w  . j  a  v  a2s  . c  om
        public void run() {
            try {
                Thread.sleep(3000);
            } catch (InterruptedException e) {
                assert true;
            }
            System.exit(0);
        }
    }, "force shutdown thread");
    t.setDaemon(true);
    t.start();
}

From source file:Watchdog.java

public synchronized void start() {
    stopped = false;/*from w ww. j  a  v a2 s.c  o  m*/
    Thread t = new Thread(this, "WATCHDOG");
    t.setDaemon(true);
    t.start();
}

From source file:org.thingsplode.agent.monitors.MonitoringExecutor.java

@PostConstruct
public void init() {
    scheduler = Executors.newScheduledThreadPool(schedulerThreadPoolSize, (Runnable r) -> {
        Thread t = new Thread(r, "SCHEDULER");
        t.setDaemon(true);
        t.setUncaughtExceptionHandler((Thread t1, Throwable e) -> {
            logger.error(String.format("Uncaught exception on thread %s. Exception %s with message %s.",
                    t1.getName(), e.getClass().getSimpleName(), e.getMessage()), e);
        });/*from   www  . j  ava2  s  .  c  o m*/
        return t;
    });
    if (autoInitializeSystemMetricProvider) {
        addProvider(new SystemMetricProvider(), 60);
    }
    if (autoInitializeThreadMetricProvider) {
        addProvider(new ThreadMetricProvider(), 300);
    }
    scheduleProviders();
}

From source file:edu.brown.workload.Workload.java

public static void writeTransactionToStream(Database catalog_db, TransactionTrace xact, OutputStream output,
        boolean multithreaded) {
    if (multithreaded) {
        if (writerThread == null) {
            synchronized (Workload.class) {
                if (writerThread == null) {
                    writerThread = new WorkloadUtil.WriteThread(catalog_db, output);
                    Thread t = new Thread(writerThread);
                    t.setDaemon(true);
                    t.start();//ww w  .  j  a  v a  2s.  c  om
                }
            } // SYNCH
        }
        writerThread.traces.offer(xact);
    } else {
        synchronized (Workload.class) {
            WorkloadUtil.WriteThread.write(catalog_db, xact, output);
        } // SYNCH
    }
}