I was recently asked when not to use mulit-threading so I gave them the best answer possible. I think my answer below fits the bill pretty nicely.
- On a single processor machine and a desktop application, you use
multi threads so you don't freeze the app but for nothing else really.
- On a single processor server and a web based app, no need for multi threading because IIS handles most of it.
- On a multi processor machine and desktop app, you are suggested to
use multi threads and parallel programming. Make as many threads as
there are processors.
- On a mulit processor server and a web based app, no need again for multi threads because IIS handles it.
In total, if you use multi threads for other than un-freezing
desktop apps and any other generic answer, you will make the app slower
over time IF you have a single core machine.
Why? Well because of the hardware switches. It takes time for the
hardware to switch between threads in total. On a multi core box, go
ahead and use 1 thread for each core and you will greatly see a ramp up in speed at the start and over time as the cores heat up.