I recently tried to work out how the solution to a ThreadPool class works in .NET 4.0. I tried to read through a reflected code but it seems a bit too extensive for me.
Could someone explain in simple terms how this class works i.e.
- How it stores each methods that are coming in
- Is it thread safe, supposedly multiple threads try to enqueue their methods in the thread pool?
- When it reaches the limit of available threads, how does it return to execute the remaining batch waiting in the queue when one of the threads becomes free? Is there some callback mechanism for it?
Of course, in the absence of the actual implementation (or in the absence of Eric Lippert 🙂 ) what I’m saying is only common sense:
QueueUserWorkItem).