Why the output for the following program is always 10 threads? I tried to change the max number of threads to the thread pool to 500 but it doesn't change anything.
class Program
{
private static object _locker = new object();
static void Main(string[] args)
{
var data = new Dictionary<int, DateTime>();
Parallel.For(0, 100000000, new ParallelOptions { MaxDegreeOfParallelism = 500 },
i =>
{
lock (_locker)
{
if (!data.ContainsKey(Thread.CurrentThread.ManagedThreadId))
{
data.Add(Thread.CurrentThread.ManagedThreadId, DateTime.Now);
Console.WriteLine($"{DateTime.Now}, {Thread.CurrentThread.ManagedThreadId}");
}
}
});
}
}