Home » Java Thread setName() Method with Examples

Java Thread setName() Method with Examples

by Online Tutorials Library

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: Tutor Aspire Team  running...  running...  After changing name of t2: TutorAspire 

You may also like