Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are threads executed on multiple processors?

It appears that the Task class provides us the ability to use multiple processors of the system. Does the Thread class work on multiple processors as well or does it use time slicing only on a single processor? (Assuming a system with multiple cores).

My question is if threads will/could be executed on multiple cores then what is so special about Task and Parallelism ?

like image 998
CriketerOnSO Avatar asked Oct 03 '14 15:10

CriketerOnSO


1 Answers

When you create a thread it forms kind of a logical group of work. The .NET Framework will aquire CPU-Time from the system. Most likely multiple threads will run on different cores (This is something the system handeles - not even .NET has any influence on this)

But it might be possible that the system will execute all your Threads on the same core or even moves the execution between several cores during the execution. Keep in Mind, that you are crating managed Threads, and not real System-Threads.

(Correctly spoken I should say: The System could execute your managed Threads within the same System-Thread or use multiple System-Threads for multiple managed threads.)

Maybe you want to have a look at this Blog-Post: http://www.drdobbs.com/parallel/managed-threads-are-different-from-windo/228800359 The explanation there is pretty good in terms of details.

like image 118
dognose Avatar answered Oct 17 '22 20:10

dognose