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 if the given thread belongs to the managed thread pool. Otherwise, return false. The return type of this property is System.Boolean.
Below programs illustrate the use of IsThreadPoolThread property:
Example 1:
// C# program to illustrate the use // of IsThreadPoolThread property using System; using System.Threading; class GFG { // Main Method static public void Main() { Thread T; // Get the reference of main Thread // Using CurrentThread property T = Thread.CurrentThread; // Check if the main thread belongs to // the managed thread pool or not // Using IsThreadPoolThread property Console.WriteLine("Is main thread belongs to Thread"+ " pool? : {0} ", T.IsThreadPoolThread); } } |
Output:
Is main thread belongs to Thread pool? : False
Example 2:
// C# program to illustrate the use // of IsThreadPoolThread property using System; using System.Threading; class GFG { // Main method public static void Main() { // Creating and initializing threads Thread TR1 = new Thread(new ThreadStart(job)); ThreadPool.QueueUserWorkItem(new WaitCallback(job1)); TR1.Start(); } // Static methods public static void job() { Console.WriteLine("Is thread 1 belongs to thread pool: {0}", Thread.CurrentThread.IsThreadPoolThread); } public static void job1(object stateInfo) { Console.WriteLine("Is thread 2 belongs to thread pool: {0}", Thread.CurrentThread.IsThreadPoolThread); } } |
Output:
Is thread 1 belongs to thread pool: False Is thread 2 belongs to thread pool: True
Reference:
Recommended Posts:
- C# | Getting the unique identifier for the current managed thread
- Difference between Managed and Unmanaged code in .NET
- Managed code and Unmanaged code in .NET
- How to check whether a thread is a background thread or not in C#
- Naming a thread and fetching name of current thread in C#
- C# | Check if an array is synchronized (thread safe) or not
- How to check whether a thread is alive or not in C#
- C# | Check if StringCollection is synchronized (thread safe)
- C# | Check if the BitArray is synchronized (thread safe)
- C# | Check if StringDictionary is synchronized (thread safe)
- C# | Check if ListDictionary is synchronized (thread safe)
- C# | Check if HybridDictionary is Synchronized (thread safe)
- C# | Check if Hashtable is synchronized (thread safe)
- C# | Check if ArrayList is Synchronized (thread safe)
- C# | How to check current state of a thread
- C# | Creating a synchronized (thread-safe) wrapper for a SortedList object
- Thread.CurrentThread Property in C#
- C# | Creating a synchronized (thread-safe) wrapper for the Hashtable
- C# | Creating a synchronized (thread-safe) wrapper for the ArrayList
- C# | Thread Priority in Multithreading
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

