how to get current thread in java?

The currentThread() method of Thread class is used to get current thread in java. It is a static method.
Syntax of currentThread() method:

public static Thread currentThread()

It returns a reference to the currently running thread.

Get current thread example

package com.w3spoint;
public class Test {
	public static void main(String args[]){
		Thread currentThread = Thread.currentThread();


Content Protection by
Please Share