Home » Java Thread getId() Method with Examples

Java Thread getId() Method with Examples

by Online Tutorials Library

Java Thread getId() method

The getId() method is used to return the thread identifier. The thread ID is a unique positive number which was generated at the time of thread creation.

The thread ID remains unchanged during its lifetime. When the thread is terminated, the ID of thread can be reused.

Syntax

Return

Example

Test it Now

Output:

Name of t1: Thread-0  Id of t1: 21  running...  

You may also like