The programming model must have compatibility and / or memory model . For example, Java has threads and this memory model (a review on Wikipedia). This clearly refers to the semantics of the programming language, its specification.
Other programming languages โโmay have other concurrency abstractions (think of clojure with agents, etc.) or a different memory model. The simpler the memory model, the easier it is to use the language. Conversely, a complex memory model makes concurrency quite difficult to do correctly (think of the definition of volatile in Java). Therefore, some people argue that programming languages โโshould not have memory models.
Actual implementation The concurrency and / or memory model depends on the language performer. You can use the process / thread of the OS , or the VM can emulate threads (the so-called green thread ). There is even another approach to ultralight flows , for example Kilim .
However, in order to actually use multi-core , you must use OS threads (one per core), otherwise parallelism hardware. But the "logical" threads used by the program can be scheduled in an easy way in threads of the N OS. As far as I know, it is impossible to tell the JVM how many OS threads to use for scheduling green threads. If anyone has a pointer to this, it would be interesting.
In short: multithreading is a logical concept. An application can be multithreaded, but run on a single core. Multicore parallelism is a hardware concept. To use mutlicore parallelism, a virtual machine must implement threads in order to use an OS process that will run on different cores.
EDIT
In fact, the Java thread and memory model is now described in a special JSR-133 specification instead of chapter 17 of the Java Language Specification. Additional Information on JSR-133 Frequently Asked Questions
ewernli
source share