I've been reading a lot about how parallelism is different than concurrency, but I'm having a lot of questions like how can I achieve a parallelism with a programming language like Java?
What I understood so far is with a VM like Java we can only achieve concurrency and parallelism is not in scope of JVM, it's threads mapped to ( I'm confused here ) OS threads or Kernel threads?
To understand the multi-threading one needs to understand how the threads of a VM ( JVM ) or a process are actually mapped down to the CPU hardware. Please help here.
Correct me if I'm wrong, here are few things I think I understand right:
1. CPU threads ( Intel hyper-threading ): Hardware threads provided by adding more registers in CPU having same ALU, so do not actually behave as a dual-CPU ( if 2 threads are there in CPU ) and a "just"-concurrent use of ALU can just mask ( hide by an interleaved MUXing ) a principal inability to deliver indeed a true parallel code-execution.
2. Kernel threads: Started by Kernel and these can be more in number than CPU threads but are a bit expensive to start.
3. OS threads: I don't understand it. I'm guessing this is what you mean when you call native threads and probably same as previous #2 ie Kernel threads.
4. User threads: Just like new Thread()
in JVM or .NET. I think they are not recognized as threads by OS so nothing much can be done here from the parallelism perspective.
I need to understand how threads created in #4 are mapped to #1, may be with examples to Windows/Linux/MacOS.
Guys, I understand how wide this question can be but I can live with brief info and link to any detailed documentation. Thanks in advance.
I understand how wide this question can be but I can live with brief info and link to any detailed documentation.
- For avoid "too broad" you mark your question as off-topic because of "resource request". Actually, as others noted, your question has so many misconceptions, so it is unclear how to ask on it in a brief manner. – Kalvin