3 ms·
I don't think there is anything wrong with Java as a language, but I have a question for you. Does Java's concurrency engine allow for many threads like Go or i
by jamra 13y ago
I don't think there is anything wrong with Java as a language, but I have a question for you. Does Java's concurrency engine allow for many threads like Go or is it similar to C# in how your threads are not lightweight and are therefore limited to ixN where N is the number of CPU cores and i is a small integer < 10.
- pron 13y agoJava doesn't have a "concurrency engine", but a very large set of concurrency primitives: schedulers, locking and lock-free data structures, atomics etc. To answer your question, yes: my own library, Quasar[1], provides lightweight threads for Java. [1]: https://github.com/puniverse/quasar https://github.com/puniverse/quasar
- pjmlp 13y agoThe Java language specification does not define how threads are implemented. The first set of JVMs did implement green threads, which are what goroutines are. Shortly thereafter most of them switched to red threads, aka real threads. You can still find a few JVMs that use green threads, like Squawk. https://java.net/projects/squawk/pages/SquawkDesign https://java.net/projects/squawk/pages/SquawkDesign Other than that, java.util.concurrent provides mechanisms to map multiple tasks to single OS threads.
- pcwalton 13y agoYou can't spawn 80 1:1 pthreads on an 8-core machine? Huh? Operating systems have been able to handle an order of magnitude more pthreads than that since the day pthreads were introduced.