Example usage for java.lang Thread currentThread

List of usage examples for java.lang Thread currentThread

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public static native Thread currentThread();

Source Link

Document

Returns a reference to the currently executing thread object.

Usage

From source file:Main.java

public static String currentThreadName() {
    return Thread.currentThread().getName();
}

From source file:Main.java

public static long getThreadId() {

    Thread t = Thread.currentThread();
    return t.getId();
}

From source file:Main.java

public static void updateThreadName(String name) {
    Thread.currentThread().setName(name);
}

From source file:Main.java

private static StackTraceElement getCall() {
    return Thread.currentThread().getStackTrace()[4];
}

From source file:Main.java

public static void waitThis() {
    try {/*from   w ww. j  a  v  a  2  s .  c  o m*/
        Thread.currentThread().wait();
    } catch (InterruptedException e) {
        throw new RuntimeException(e);
    }
}

From source file:Main.java

public static String getThreadId() {
    return String.valueOf(Thread.currentThread().getId());
}

From source file:Main.java

public static String getCallerNoPackageClassName() {
    return Thread.currentThread().getStackTrace()[2].getClassName().replaceAll(".*\\.", "");
}

From source file:Main.java

public static String getThreadInfo() {
    return "@[name=" + Thread.currentThread().getName() + ", id=" + Thread.currentThread().getId() + "]";
}

From source file:Main.java

public static StackTraceElement[] getStackTrace() {
    return Thread.currentThread().getStackTrace();
}

From source file:Main.java

public static ClassLoader getContextClassLoader() {
    return Thread.currentThread().getContextClassLoader();
}