-2

In a multi threaded environment,

Single core processor

When two threads execute in a single core processor, then the two threads execute concurrently.

Multi-core(Dual core) processor

When two threads execute in a multi core processor, then these the two threads will execute in parallel. Is my understanding is correct?

pradeep
  • 295
  • 4
  • 17
  • this is with respect to java multithreading concept – pradeep Jul 17 '18 at 08:46
  • Maybe, but not necessarily. It's up to the OS. The OS can decide that 2 threads will simply timeshare a single core, and just swaps back and forth between them. – Michael Jul 17 '18 at 08:47
  • You understand that even single cores have multiple pipelines these days, and that they are often able to run 2, 4, 8 threads in parallel? – GhostCat Jul 17 '18 at 08:55
  • Two threads running "concurrently" means that both were started before either one of them finished. So, any time you have different threads running at the same time on different processors, they are both running in parallel, _and_ running concurrently. Any time you have parallelism, you also have concurrency. – Solomon Slow Jul 17 '18 at 14:29

1 Answers1

6

Theoretically they can be executed in parallel. In fact this depends on some other factors. For example, you are not alone on your system. There are other processes. They can require CPU time as well, so there is a chance that your threads will not get the time slot on time and your threads in fact will be executed sequentially.

AlexR
  • 114,158
  • 16
  • 130
  • 208