Well, the best place to start is the documentation for the Thread class. Which says:
Returns a reference to the currently executing thread object.
currentThread() is a static method of Thread (which is why you don't need a reference to a Thread object to call it). It returns a reference to a Thread object, and it will always return a reference to the Thread that it's executed in.
sudharani Savadi wrote:Still I am getting confusion about Thread name because Thread[main,5,main], it contains two mains so I am not getting which one is thread name and main method name. can you tell me in detail?
I assume you're getting that by printing the value of a Thread (which will use the toString() method)? Well, to be sure you could create your own Thread object, give it a different name, and print that out. But you can get an indication again by checking the documentation. From Thread.toString():
Returns a string representation of this thread, including the thread's name, priority, and thread group.
So the likelihood is that the first "main" is the name, and the second "main" is the thread group name. But trying your own experiment is the best way to be certain.