3 ms·
"The Java concurrency primitives like locks and synchronized have been proven to be too low level and often to hard to use" synchronized is not hard to use. it
by _giu 17y ago
"The Java concurrency primitives like locks and synchronized have been proven to be too low level and often to hard to use"
synchronized is not hard to use. it's rather not a good practice to use it, since it will slow down code massively.
- gdp 17y agoConcurrency in general is hard. You'll find that most uses of concurrency in production systems is restricted to very specific patterns. This is probably not a conscious decision, rather it's just very likely that straying too far from very simple models of interaction between concurrent processes is actually just beyond the intellectual scope of most people. I do concurrency theory for a living, and concurrency primitives in Java still give me nightmares.
- uriel 17y agoConcurrency is hard only if you use the common 'pthread-like' model. There are much better alternatives like Erlang and CSP ( http://books.cat-v.org/computer-science/csp/ http://books.cat-v.org/computer-science/csp/ )
- zmimon 17y agoActually synchronized is not that expensive in itself. Especially in modern implementations it's not bad at all. It always used to amuse me how Java developers would go to contortions trying not to synchronize a method and then they'd fill it up with calls to things like Vector (every method synchronized!), StringBuffer (yep, every method synchronized!) and any number of other calls that are synchronized in the default JDK.