Example usage for java.lang Thread getName

List of usage examples for java.lang Thread getName

Introduction

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

Prototype

public final String getName() 

Source Link

Document

Returns this thread's name.

Usage

From source file:TwoThreadSetName.java

public void printMsg() {
    Thread t = Thread.currentThread();
    String name = t.getName();
    System.out.println("name=" + name);
}

From source file:Main.java

public void run() {

    Thread t = Thread.currentThread();
    System.out.print(t.getName());
    System.out.println(", status = " + t.isAlive());
}

From source file:Main.java

public void run() {

    Thread t = Thread.currentThread();
    System.out.print(t.getName());

    System.out.println(", status = " + t.isAlive());
}

From source file:Main.java

public void run() {

    Thread t = Thread.currentThread();
    System.out.print(t.getName());
    // checks if this thread is alive
    System.out.println(", status = " + t.isAlive());
}

From source file:Main.java

@Override
public void run() {
    Thread t = Thread.currentThread();
    String threadName = t.getName();
    System.out.println("Inside run() method:  " + threadName);
}

From source file:TwoThreadSleep.java

public void run() {
    Thread t = Thread.currentThread();
    String name = t.getName();

    System.out.println("entered loop() - " + name);

    for (int i = 0; i < 10; i++) {
        try {/*from   ww  w  .ja  v  a  2  s.  c o m*/
            Thread.sleep(200);
        } catch (InterruptedException x) {
        }

        System.out.println("name=" + name);
    }
    System.out.println("leave loop() - " + name);

}

From source file:CatchAllThreadExceptionHandler.java

public void uncaughtException(Thread t, Throwable e) {
    System.out.println("Caught  Exception from  Thread:" + t.getName());
}

From source file:Main.java

public ThreadGroupDemo() {
    ThreadGroup pGroup = new ThreadGroup("Parent ThreadGroup");

    ThreadGroup cGroup = new ThreadGroup(pGroup, "Child ThreadGroup");

    Thread t1 = new Thread(pGroup, this);
    System.out.println("Starting " + t1.getName());
    t1.start();//from w w w  .j  av a  2 s  .c o m

    Thread t2 = new Thread(cGroup, this);
    System.out.println("Starting " + t2.getName());
    t2.start();

}

From source file:Main.java

public ThreadGroupDemo() {
    ThreadGroup pGroup = new ThreadGroup("Parent ThreadGroup");

    ThreadGroup cGroup = new ThreadGroup(pGroup, "Child ThreadGroup");

    Thread t1 = new Thread(pGroup, this);
    System.out.println("Starting " + t1.getName());
    t1.start();//from w w w .j  ava 2  s . c  om

    Thread t2 = new Thread(cGroup, this);
    System.out.println("Starting " + t2.getName());
    t2.start();

    System.out.println("Active group(child) threads in \"" + pGroup.getName() + "\" = " + pGroup.activeCount());

}

From source file:Main.java

public ThreadGroupDemo() {
    ThreadGroup pGroup = new ThreadGroup("Parent ThreadGroup");

    ThreadGroup cGroup = new ThreadGroup(pGroup, "Child ThreadGroup");

    Thread t1 = new Thread(pGroup, this);
    System.out.println("Starting " + t1.getName());
    t1.start();/*  w  ww . j av  a2  s .c o  m*/

    Thread t2 = new Thread(cGroup, this);
    System.out.println("Starting " + t2.getName());
    t2.start();

    System.out.println("ParentThreadGroup for " + pGroup.getName() + " is " + pGroup.getParent().getName());
    System.out.println("ParentThreadGroup for " + cGroup.getName() + " is " + cGroup.getParent().getName());

}