Example usage for java.lang Thread setName

List of usage examples for java.lang Thread setName

Introduction

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

Prototype

public final synchronized void setName(String name) 

Source Link

Document

Changes the name of this thread to be equal to the argument name .

Usage

From source file:Main.java

public static void main(String[] args) {

    Thread t = Thread.currentThread();
    t.setName("java2s.com thread");
    // set thread priority to 1
    t.setPriority(1);/*ww  w .  ja v  a2 s.  c  o  m*/

    System.out.println("Thread = " + t);

    int count = Thread.activeCount();
    System.out.println("currently active threads = " + count);
}

From source file:Main.java

public static void main(String[] args) {

    Thread t = Thread.currentThread();
    t.setName("java2s.com thread");

    System.out.println("Thread = " + t);

    int count = Thread.activeCount();
    System.out.println("currently active threads = " + count);

    Thread.dumpStack();//from  w  w w.  ja v a 2 s  . c om
}

From source file:Main.java

public static void main(String[] args) {

    Thread t = Thread.currentThread();
    t.setName("java2s.com thread");
    // set thread priority to 1
    t.setPriority(Thread.NORM_PRIORITY);

    System.out.println("Thread = " + t);

    int count = Thread.activeCount();
    System.out.println("currently active threads = " + count);
}

From source file:Main.java

public static void main(String[] args) {

    Thread t = Thread.currentThread();
    t.setName("java2s.com thread");
    // set thread priority to 1
    t.setPriority(Thread.MIN_PRIORITY);

    System.out.println("Thread = " + t);

    int count = Thread.activeCount();
    System.out.println("currently active threads = " + count);
}

From source file:Main.java

public static void main(String[] args) {

    Thread t = Thread.currentThread();
    t.setName("java2s.com thread");
    // set thread priority to 1
    t.setPriority(Thread.MAX_PRIORITY);

    System.out.println("Thread = " + t);

    int count = Thread.activeCount();
    System.out.println("currently active threads = " + count);
}

From source file:Main.java

public static void main(String[] args) {
    Main ttsn = new Main();
    ttsn.setName("Created One");
    ttsn.start();/*from  www .j av a  2s . com*/

    Thread t2 = currentThread();
    t2.setName("Main One");

    for (int i = 0; i < 5; i++) {
        ttsn.printMyName();
    }
}

From source file:Main.java

public static void main(String[] args) {
    Thread t = Thread.currentThread();
    t.setName("java2s.com thread");

    System.out.println("Thread = " + t);

    int count = Thread.activeCount();
    System.out.println("currently active threads = " + count);

    Thread th[] = new Thread[count];
    Thread.enumerate(th);//w  w  w  .java2s . co  m

    for (int i = 0; i < count; i++) {
        System.out.println(i + ": " + th[i]);
    }
}

From source file:MainClass.java

public static void main(String args[]) {
    Thread t = Thread.currentThread();
    t.setName("My Thread");
    t.setPriority(1);//from   ww  w .  j a  va2 s  .com
    System.out.println("current thread: " + t);
    int active = Thread.activeCount();
    System.out.println("currently active threads: " + active);
    Thread all[] = new Thread[active];
    Thread.enumerate(all);
    for (int i = 0; i < active; i++) {
        System.out.println(i + ": " + all[i]);
    }
    Thread.dumpStack();
}

From source file:Main.java

public static void main(String[] args) {

    Thread t = Thread.currentThread();
    System.out.println("Thread = " + t);

    t.setName("java2s.com thread");

    System.out.println("Thread after changing name = " + t);

    int count = Thread.activeCount();
    System.out.println("currently active threads = " + count);
}

From source file:io.gravitee.gateway.platforms.jetty.bootstrap.Bootstrap.java

public static void main(String[] args) {
    Thread t = Thread.currentThread();
    t.setName("graviteeio-gateway");

    final AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    ctx.register(JettyConfiguration.class);
    ctx.registerShutdownHook();//from w w w . ja v a 2s. com
    ctx.refresh();

    try {
        final Node node = ctx.getBean(Node.class);
        node.start();

        Runtime.getRuntime().addShutdownHook(new Thread() {
            @Override
            public void run() {
                LoggerFactory.getLogger(Bootstrap.class).info("Shutting-down Gravitee Gateway...");
                node.stop();
                ctx.close();
            }
        });
    } catch (Exception ex) {
        LOGGER.error("Unable to start Gravitee Gateway", ex);
    }
}