73
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
Output:
Name of t1: Thread-0 Id of t1: 21 running...
Next TopicMultithreading in Java