none
Dot net threads vs CLR threads RRS feed

  • Question

  • Hi All,

    I'm looking into how to use Threading Tasks and keep seeing the Tasks uses the CLR thread pool as opposed to dot net thread pool what is the difference?

    Thanks,

    Mike

    Monday, September 8, 2014 9:36 PM

Answers

  • CLR and "dot net" are the same thing, at least when it comes to your question. There's only one thread pool and it is represented by the System.Threading.ThreadPool class, that's what tasks are using.
    • Marked as answer by Bulldog61 Friday, September 12, 2014 4:53 PM
    Tuesday, September 9, 2014 5:08 AM
    Moderator

All replies

  • CLR and "dot net" are the same thing, at least when it comes to your question. There's only one thread pool and it is represented by the System.Threading.ThreadPool class, that's what tasks are using.
    • Marked as answer by Bulldog61 Friday, September 12, 2014 4:53 PM
    Tuesday, September 9, 2014 5:08 AM
    Moderator
  • CLR is a part of .NET Framework, so CLR thread is a sub thread in the main thread of .Net Framework
    Tuesday, September 9, 2014 5:53 AM
  • "so CLR thread is a sub thread in the main thread of .Net Framework"

    There are no such things as CLR thread, .NET Framework thread or "sub thread in the main thread". There's only one Thread class in the .NET Framework and CLR is what makes it work.

    Tuesday, September 9, 2014 6:43 AM
    Moderator
  • Hello Mike Danes,

    There's only one Thread class in the .NET Framework and CLR is what makes it work.

    The Thread class in the .NET Framework contains true and right codes so it can work by itself, CLR is just an immediate environment between codes in the Thread class and native code.

    Tuesday, September 9, 2014 7:07 AM
  • Actually the Thread class contains almost no code, most of the functionality is provided by the CLR. Please refrain from making dubious statements which only serve to muddy the waters.
    Tuesday, September 9, 2014 7:25 AM
    Moderator
  • You can use Thread class to do some works as follows:

     class Work
        {
    
            static void Main(string[] args)
            {
                Work work = new Work();
                Thread thread = new Thread(work.DoWork);
                thread.Start("Please say something about CLR!");
                Thread.Sleep(1000);      
                thread = new Thread(work.DoMoreWork);
                thread.Start("It will be enough if you tell more about DLR.");
                Thread.Sleep(1000);
            }
    
            private void DoWork(dynamic data)
            {
                Console.WriteLine("This is a main task: {0}", data);
            }
            private void DoMoreWork(dynamic data)
            {
                Console.WriteLine("This is an additional task: {0}", data);
            }
        } 

    Tuesday, September 9, 2014 8:22 AM