Anil Deshpande wrote:Current Thread is a static method in Thread class. It returns the Thread name,priority (by default 5 i.e NORM_PRIORITY) and method name in which it was invoked.
Not true. It returns a reference to the currently running Thread. See the API: java.lang.Thread.
i.e if you call method currentThread in run mthod of Thread and then start thread from the main method, answer would be like
Which is the output for Thread#toString(). So this output is only returned when you call Thread.currentThread().toString() (or send the thread reference to some other method which does the toString() part, for example by calling System.out.println(Thread.currentThread()))
posted 11 years ago
Yeah, That os more precise answer
SCJP 1.5, SCWCD 1.5
Eat that pie! EAT IT! Now read this tiny ad. READ IT!