This may be a beginner's question. Is there a difference between executing multiple threads and running a program multiple times? By running a program multiple times, I mean literally starting up a terminal and running the program multiple times. I read that there is a limit of 1 thread per CPU, and I have a quad-core machine, so I guess that means I have 4 CPUs. Is there a limit of programs per CPU also?
2 Answers
Generally, if a program uses multiple threads, the threads will divide the work of the program between themselves. For example, one thread might work on half of a giant data set and another thread might take the other half, or multiple threads might talk to separate machines across a network. Running a program 2 times won't have that effect; you'll get two webservers or two games of Minecraft that have nothing to do with each other. It's possible for a program to communicate with other copies of itself, and some programs do that, but it's not the usual approach.

- 260,549
- 28
- 431
- 505
-
@kolonel: That's a very vague question. What do you mean by "in terms of processing"? I'm not sure what information you're looking for, and spewing facts until I say the right things isn't an efficient way to communicate. – user2357112 Jan 09 '14 at 07:42
-
I'm not spewing facts, on the contrary I am trying to understand the facts. If I have a quad-core machine, assume I am not worried about how long execution takes (I am but for now let us assume not). If there are more than 4 threads executed , and we know that each CPU can execute one thread at a time, and the rest "wait in line", then is it the same if I ran the programs more than 5 times? Hope this is better... – kolonel Jan 09 '14 at 07:51
-
@kolonel: I meant that *I* could spew facts at you until I explain the part you want explained, but I'd probably go through 3 topics you already understand and 5 you don't care about before I get the right part. – user2357112 Jan 09 '14 at 07:54
-
1As for your question, 5 independent programs will compete for CPU time much like 5 independent threads. The details can be complex; it's more work to switch processes than to switch threads, and there are tricks we use to get multiple processes or threads executing simultaneously on a single core, but in both cases, there will be contention for CPU time. – user2357112 Jan 09 '14 at 07:57
-
Ok thanks. Could you direct me to a good article of threading in python? – kolonel Jan 09 '14 at 08:00
-
1@kolonel: I don't know any, but I found a [StackOverflow question](http://stackoverflow.com/questions/1190206/threading-in-python) with a good answer after a quick search. – user2357112 Jan 09 '14 at 08:01
Multiple Threads means you can execute different instances of an action in same time. If you running multiple programs it will execute one by one . Using thread we can increase the processing speed by parallel process

- 410
- 1
- 5
- 14