Javatpoint Logo
Javatpoint Logo

Java Thread setName() method

The setName() method of thread class is used to change the name of the thread.

Syntax

Parameter

Return

Exception

SecurityException: This exception throws if the current thread cannot modify the thread.

Example

Test it Now

Output:

After changing name of t1: Sonoo Jaiswal
running...
running...
After changing name of t2: javatpoint






Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA