What happens when you create too many threads? Does it cause the CPU to crash or is there some sort of internal load balancing mechanism on Windows OS'?
I'm running the following code:
private async void A(string[] a)
{
var tasks = a.Select(B);
await Task.WhenAll(tasks);
}
private async Task B(string b)
{
new Thread(async delegate ()
{
//all the work that needs to be done
}).Start();
}
I'm running an array of async Tasks but within each async method I've encapsulated all the work that needs to be done in a new thread. What happens if I call B a large number of times? How will the processor deal with too many threads?