Click here to Skip to main content
15,920,217 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am running the sample .Net Console application just to check the number of threads created in the Task Manager. But the no of threads running for the below code in Task Manager is 10?
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication7
{
    class Program
    {
        static void Main(string[] args)
        {

            Console.WriteLine("Testing--";);
        }
    }
}

Can anyone let me know how many default threads should run for thr above code in Task Manager?
Posted
Updated 29-May-12 3:19am
v2

Depends on the system configuration and weather you run it from VisualStudion or already compiled, you run it or trace it... In case of a step by step trace from within Visual Studio, 10 treads are normal.
 
Share this answer
 
One for the program, and one for garbage collection.

According to the Microsoft documentation[^].,


"The thread pool is created the first time you create an instance of the ThreadPool class. The thread pool has a default limit of 25 threads per available processor, which could be changed using CorSetMaxThreads as defined in the mscoree.h file. Each thread uses the default stack size and runs at the default priority. Each process can have only one operating system thread pool."


The CLR may create extra threads for the thread pool just in case you need them, but your code won't run on them unless you explicitly make it happen.

You can see threads being created if you watch the Output panel in Visual Studio while your app is running.
 
Share this answer
 
v2
Comments
Zoltán Zörgő 29-May-12 9:36am    
There is no thread pool in his code. Don't mislead him.
jpratik 6-Jun-12 6:24am    
True, there isn't any thread pool but just giving him a general overview.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900