.NET mulithreading and quad core processors

multithreadingvb.net

I have a single threaded application that runs on a machine with a quad core processor. The scheduled tasks that run VB.NET forms are too slow.

I am new to multi threading and parallel computing. If you have a single threaded application that runs on a server with a multi core processor then does the application only ever use one of the processors? What happens if you have multiple scheduled tasks and multiple instances are in memory at the same time?

I have read this question on Stackoverflow: https://stackoverflow.com/questions/607775/how-to-write-net-applications-that-utilize-multi-core-processors, but I am still not clear.

Best Answer

A process will have one thread, unless you tell it otherwise. Two processes then have two threads total. Each core on a processor can run one thread at a time. So, if you have a processor with 2 cores (or 2 processors with 1 core each):

  • If you have one process with one thread, it will only ever run on one of the cores at a time (note that it can switch between cores, but will never use both at the same time).

  • If you have two processes with one thread each, they can (but might not) both run at the same time (on different cores and/or different processors).

  • If you have one process with two threads, both threads can (but might not) run at the same time (on different cores and/or different processors).