Example usage for java.lang Thread Thread

List of usage examples for java.lang Thread Thread

Introduction

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

Prototype

public Thread(Runnable target, String name) 

Source Link

Document

Allocates a new Thread object.

Usage

From source file:SyncBlock.java

private static Thread launch(final SyncBlock sb, String name) {

    Runnable r = new Runnable() {
        public void run() {
            print("in run()");
            sb.doStuff();/*from  w ww . j  av  a 2s .com*/
        }
    };

    Thread t = new Thread(r, name);
    t.start();

    return t;
}

From source file:Main.java

public static ThreadFactory daemonThreadFactory(final String name) {
    return new ThreadFactory() {
        @Override/*  w  ww . jav a  2  s.c  om*/
        public Thread newThread(Runnable runnable) {
            Thread result = new Thread(runnable, name);
            result.setDaemon(true);
            return result;
        }
    };
}