C# | Getting the unique identifier for the current managed thread Last Updated : 11 Jul, 2025 Comments Improve Suggest changes Like Article Like Report 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: CSharp // C# program to illustrate the // use of ManagedThreadId property using System; using System.Threading; public class GFG { // Main Method static public void Main() { Thread T; // Get the reference of main Thread // Using CurrentThread property T = Thread.CurrentThread; // Display the unique id of the main // thread Using ManagedThreadId property Console.WriteLine("The unique id of the main "+ "thread is: {0} ", T.ManagedThreadId); } } Output: The unique id of the main thread is: 1 Example 2: CSharp // C# program to illustrate the // use of ManagedThreadId property using System; using System.Threading; public class GFG { // Main method public static void Main() { // Creating and initializing threads Thread thr1 = new Thread(new ThreadStart(job)); Thread thr2 = new Thread(new ThreadStart(job)); Thread thr3 = new Thread(new ThreadStart(job)); Console.WriteLine("ManagedThreadId of thread 1 "+ "is: {0}", thr1.ManagedThreadId); Console.WriteLine("ManagedThreadId of thread 2 "+ "is: {0}", thr2.ManagedThreadId); Console.WriteLine("ManagedThreadId of thread 3 "+ "is: {0}", thr3.ManagedThreadId); // Running state thr1.Start(); thr2.Start(); thr3.Start(); } // Static method public static void job() { Thread.Sleep(2000); } } Output: ManagedThreadId of thread 1 is: 3 ManagedThreadId of thread 2 is: 4 ManagedThreadId of thread 3 is: 5 Reference: https://learn.microsoft.com/en-us/dotnet/api/system.threading.thread.managedthreadid?view=netframework-4.7.2 Comment More infoAdvertise with us Next Article C# | Check if a thread belongs to managed thread pool or not A ankita_saini Follow Improve Article Tags : C# CSharp Multithreading CSharp Thread Class Similar Reads Naming a thread and fetching name of current thread in C# A thread is a light-weight process within a process. In C#, a user is allowed to assign a name to the thread and also find the name of the current working thread by using the Thread.Name property of the Thread class. Syntax : public string Name { get; set; } Here, the string contains the name of the 2 min read C# | Check if a thread belongs to managed thread pool or not A Thread class is responsible for creating and managing a thread in multi-thread programming. It provides a property known as IsThreadPoolThread to check if the thread belongs to the managed thread pool or not. Syntax: public bool IsThreadPoolThread { get; } Return Value: This property returns true 2 min read C# Program to Get Current Stack Trace Information Using Environment Class In C#, Environment Class provides information about the current platform and manipulates, the current platform. It is useful for getting and setting various operating system-related information. We can use it in such a way that it retrieves command-line arguments information, exit codes information, 2 min read C# | How to retrieve the system's reference to the specified String String.Intern(String) Method is used to retrieve the system's reference to the specified String. This method uses the intern pool to search for a string equal to the value of the specified string. If such a string exists, then its reference in the intern pool is returned, or if the string doesn't ex 3 min read Thread.CurrentThread Property in C# A Thread class is responsible for creating and managing a thread in multi-thread programming. It provides a property known as CurrentThread to check the current running thread. Or in other words, the value of this property indicates the current running thread. Syntax: public static Thread CurrentThr 2 min read C# | How to check current state of a thread A Thread class is responsible for creating and managing a thread in multi-thread programming. It provides a property known as ThreadState to check the current state of the thread. The initial state of a thread is Unstarted state. Syntax: public ThreadState ThreadState{ get; } Return Value: This prop 2 min read Like