Can any computer (multi or single core) run many threads at the same time

3k views Asked by At

i have simple but not easy question

Can any computer (multi or single core) run many threads at the same time, the very same time, i mean two or more threads runs at the same time of execution ?

5

There are 5 answers

0
AudioBubble On BEST ANSWER

The capability of running multiple threads at the same time is the reason why multicore processors are being produced. It was getting more and more difficult to boost single-core CPU's efficiency due to various reasons. At the same time, as many threads as the number of cores/processors you have can be executed. If you have multiple multicore processors, the maximum number of threads running in parallel will be num_cpus*cores_per_cpu. If the number of threads exceeds the number of available cores, they will be executed interlaced.

0
CodingLumis On

You can create multiple threads in your environment and have a single CPU core execute these threads. However, their execution will not be in parallel but merely concurrent. In other words, the CPU will execute one thread (in part or completely) first then the other thread. If there was work left on the first thread it then may return to the first thread again and execute some more instructions. The threads are thus progressing concurrently. If the threads were executed on more than one CPU core then they can be executed at the same time which means they are executed in parallel.

In summary, multiple threads on a single CPU core can be executed concurrently. Multiple threads on multiple CPU cores can be executed concurrently or in parallel.

See also this answer: Can multithreading be implemented on a single processor system?

1
Solomon Slow On

...at the same time, the very same time, i mean ... at the same time of execution...

Sounds like you are struggling to find a formal way of asking your question.

The words "at the same time" do not usually appear in formal discussions about concurrency.

When you're talking about time, there are events which are indivisible moments in time, and then there are intervals. Every interval is defined by its begin event and its end event.

Whenever you're trying to prove the behavior of some system, and your proof revolves around events, A and B then either;

  • You know or can prove that A happens before B,
  • You know or can prove that B happens before A,
  • Your proof doesn't depend on the order in which they happen, or
  • Your proof is going to fail.

Those are the only possibilities. If your proof is going to fail, then you won't be able to rescue it by saying "A and B happen at the same time."

When your proof revolves around two intervals, I and J, then either;

  • you know or can prove that I finishes before J begins, or
  • you know or can prova that J finishes before I begins, or
  • The two intervals overlap.

"Overlap" is the preferred word in formal discussions. So,...

...The execution of two or more threads can overlap on a single-processor system, but at any given instant in time, the single CPU will only be working on behalf of one of the threads.

0
Azodious On
0
Henshal B On

You've to be aware of you're CPU capabilities first.

Use those to learn how many processes your CPU can handle.

1. lscpu 
2. cat /proc/sys/kernel/threads-max
3. cat /proc/sys/kernel/pid_max
4. htop
5. top
6. cat /proc/cpuinfo
7. ulimit -a
8. ps -aeF