0

I'm learning about concurrency in java. From The Java™ Tutorials say that

Most implementations of the Java virtual machine run as a single process.

I understand the difference between concurrency and parallel execution that if we have just one processor then we cannot actual run program in parallelism.

So my question is: Could we run java program in parallel if JVM implemented as single core ?

Puskin
  • 125
  • 1
  • 11
  • 1
    Single process does not mean it runs only on a single core (note it said "process", not "processor"). See [What is the difference between a process and a thread?](https://stackoverflow.com/questions/200469/what-is-the-difference-between-a-process-and-a-thread). Also see [Process (computing) – Wikipedia](https://en.wikipedia.org/wiki/Process_(computing)). – Slaw Jul 29 '21 at 04:10
  • 1
    JVM is a single process (not core). It can have multiple threads. If the processor has multiple cores, those threads can run in parallel. Otherwise, they run concurrently. – Burak Serdar Jul 29 '21 at 04:10
  • @BurakSerdar If processor has multiple cores. I run multi-task in multiple thread and use same variable(I meant that threads is shared memory). Then those threads is just run in concurrently, right? Because threads is difference process does not share memory – Puskin Jul 29 '21 at 04:17
  • Multiple threads of a single process share the memory space of that process. Threads will share the execution time on the cores. If there is only one core, threads will run concurrently, not in parallel. If there are multiple cores, some of the threads will also run in parallel. – Burak Serdar Jul 29 '21 at 04:25
  • Does this answer your question? [Multiple Processes under one JVM](https://stackoverflow.com/questions/43935301/multiple-processes-under-one-jvm) – Tarik Jul 29 '21 at 05:09
  • See https://stackoverflow.com/questions/43935301/multiple-processes-under-one-jvm/68570319#68570319 – Tarik Jul 29 '21 at 05:11

0 Answers0