4 ms·
Is there any chance you could briefly enumerate some of the things that make the JVM's approach to concurrency so strong? I'd be interested.
by hugofirth 13y ago
Is there any chance you could briefly enumerate some of the things that make the JVM's approach to concurrency so strong? I'd be interested.
- pron 13y agoIt's not the approach, but the capabilities: 1. State-of-the-art garbage collectors, which enable good implementations of lock-free data structures. 2. Excellent implementations of lock-free data structures (like ConcurrentLinkedQueue and ConcurrentSkipListMap) and other concurrent data structures (like ConcurrentHashMap). 3. A state-of-the-art work-stealing scheduler (ForkJoinPool), excellent for both parallelism (as used by Java 8's streams) and concurrency. 4. A cross-platform memory model specifying memory visibility across threads. 5. Access to CPU concurrency primitives like CAS and memory fences. These building blocks are a great foundation for any concurrent application.
- smikhanov 13y agoCould you please elaborate on #5? What you mean there is the fact that AtomicInteger implementation is actually using this primitives on your target platform, correct?
- pron 13y agoIt's more than that. AtomicInteger's implementation uses JVM intrinsics which are calls to methods in the sun.misc.Unsafe class, that, when JITted, are replaced by a platform specific machine instruction (where available), such as CAS or a memory fence.
- hugofirth 13y agoThanks - I use Java all the time - but sometimes I find knowing which data structures to turn to in a given situation tough.
- azinman2 13y agoThat's true for any language, and any platform. The language can't save you from having to, at some point, understand how to properly engineer software.
- DaveLond 13y agoGrab a copy of "java concurrency in practice", it's my go-to book for when I've got a tricky concurrency problem to solve.