'Using Tasks recursively in C# without ThreadStarvation [closed]

I am trying to figure out if concurrent programming (Specifically with TaskScheduler, TaskFactory) in C# can lead to ThreadStarvation.

I created a fixed Threadpool in Java for a divide and conquer sort algorithm, a Task tries to create 2 new Childtasks and waits for their results to merge them. While a Task waits, the used Thread needs to wait. At some point the Threadpool can't create more Threads and the program crashes. You can fix this by using fork/join-tasks that can jump to some other work after they forked and wait for the results.

Can this phenomenon happen in C# as well? Are there also ForkJoinTasks for recursive algorithms or are they not needed because the usual Tasks can prevent this? I'm having problems finding something about the behaviour of tasks when they wait for child tasks.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source