I have multiple threads being invoked by say several other processes at the same time. Generally the thumb rule for max. number of threads that a processor can start giving performance efficiency is no. of threads = no. of processors + 1 (not sure though). All the modern applications maintain a threadpool and keep on re-using threads at any particular instance.
How can we make sure that performance won't degrade due to this. Because when it goes beyond the limit, threads keep on context switching and at any singe point, none of them will be executing the critical section of the code.
The number of threads is more dependend on the resources it uses. If the thread processes data from disk or network, it depends on how long it has to wait on that resources. During the wait another thread can do some work. For pure number crunching I would say one thread per processer/core.