Open In App

Difference Between Thread ID and Thread Handle

Prerequisite: Thread in Operating System

Thread Id is a long positive integer that is created when the thread was created. During the entire lifecycle of a thread, the thread ID is unique and remains unchanged. It can be reused when the thread is terminated. The Thread get_id() method can be studied here where we can see how it’s used.



Thread Handle is a token that allows you to do something with the thread typically wait for it or kill it.

The CreateThread() API function creates a new thread for the process. It must specify the starting address of the new thread to be executed. The CreateThread() API returns simultaneously the thread handle and the thread ID. Operations such as creating thread objects are controlled by thread handle. At the system level, the thread ID uniquely identifies the thread when the specific thread it is running. 



Difference between Thread ID and Thread Handle:

Article Tags :