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 void main(String[] args) {
    Thread t = Thread.currentThread();
    StackTraceElement e = t.getStackTrace()[0];

    System.out.println(e.hashCode());
}

From source file:Main.java

public static void main(String args[]) {
    trace(Thread.currentThread().getStackTrace());

}

From source file:Main.java

public static void main(String[] args) {
    Thread t = Thread.currentThread();
    StackTraceElement e = t.getStackTrace()[0];
    System.out.print("class name : ");
    System.out.print(e.getClassName());
}

From source file:Main.java

public static void main(String[] args) {
    Thread t = Thread.currentThread();
    StackTraceElement e = t.getStackTrace()[0];
    System.out.print("file name : ");
    System.out.print(e.getFileName());
}

From source file:Main.java

public static void main(String[] args) {

    Thread t = Thread.currentThread();
    StackTraceElement e = t.getStackTrace()[0];
    System.out.println(e.getMethodName());
}

From source file:Main.java

public static void main(String[] args) {
    Thread t = Thread.currentThread();
    StackTraceElement e = t.getStackTrace()[0];

    Object ob = "a";
    System.out.println(e.equals(ob));
}

From source file:Main.java

public static void main(String[] args) {
    System.out.println(Thread.currentThread().getStackTrace()[0].getClassName());
}

From source file:MyThread.java

public static void main(String[] args) throws Exception {

    Thread thread = new MyThread();
    System.out.println("thread = " + thread.currentThread());
    thread.setDaemon(false);/*from   w w w .j  a va 2  s. c om*/

    thread.start();
}

From source file:Main.java

public static void main(String[] args) {
    Thread t = Thread.currentThread();
    StackTraceElement e = t.getStackTrace()[0];

    System.out.print("line number : ");
    System.out.print(e.getLineNumber());
}

From source file:Main.java

public static void main(String[] args) {

    Thread t = Thread.currentThread();
    StackTraceElement e = t.getStackTrace()[0];
    System.out.println(e.toString());

}