VOOZH about

URL: https://www.geeksforgeeks.org/c-sharp/c-sharp-getting-the-unique-identifier-for-the-current-managed-thread/

⇱ C# | Getting the unique identifier for the current managed thread - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

C# | Getting the unique identifier for the current managed thread

Last Updated : 11 Jul, 2025
A Thread class is responsible for creating and managing a thread in multi-thread programming. It provides a property known as ManagedThreadId to check the unique identifier for the current managed thread. Or in other words, the value of ManagedThreadId property of a thread defines uniquely that thread within its process. The value of the ManagedThreadId property does not vary according to time. Syntax:
public int ManagedThreadId { get; }
Return Value: This property returns a value that indicates a unique identifier for this managed thread. The return type of this property is System.Int32. Example 1: Output:
The unique id of the main thread is: 1 
Example 2:
Output:
ManagedThreadId of thread 1 is: 3
ManagedThreadId of thread 2 is: 4
ManagedThreadId of thread 3 is: 5
Reference:
Comment

Explore