A quick question, what will happen if i invoke setName(String) API on a thread instance after it has been started via "start()". Will the name be at on the thread and printing it would print the new name? or the name can not be set after the thread has been started?
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
subodh k kumar
posted 6 years ago
Yes,Inside your run() method you can access the Current thread and reset the name of it.This will print the new Thread Name.
Thread currentThread = Thread.currentThread();