In this example we will show about how to get current thread with currentThread method of Thread class in Java.
Source Code
package com.beginner.examples;
public class GetThreadExample {
public static void main(String[] args){
//get current thread
Thread thread = Thread.currentThread();
System.out.println(thread);
}
}
Output:
Thread[main,5,main]