0

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 2

2

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.

Sign up to request clarification or add additional context in comments.

6 Comments

@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.
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: 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.
As 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.
@kolonel: I don't know any, but I found a StackOverflow question with a good answer after a quick search.
|
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.