Concurrency Patterns: Java, Scala, and Clojure
fupeg.blogspot.com
fupeg.blogspot.com
Ah, another person who's never come close to examining Scala's actor implementation. Check out scala.actors.FJTaskScheduler2. It uses threads. That's, uh, kind of the only way to get a JVM process to do things concurrently.
While it may use threads, Scala's actor system effectively allows you to create thousands of actors.
Kilim is actually a pure (depending on whether you see a byte-code processing system as pure) Java system that does the same thing (as far as I can tell): http://www.malhar.net/sriram/kilim/
Kilim's author did a nice Google Talk: http://www.youtube.com/watch?v=37NaHRE0Sqw
EDIT: Fixed some grammar and added video link.
In particular, the author's concern regarding management of mutable data structures in STM is almost bizzare. The concurrent code that I have worked with uses persistent but immutable data structures across agents, which are execution blocks queued in a thread pool. Using this you can write large pieces of code without dosync that scale to any number of cores in an efficient manner.
So, while I enjoy comparisons and nice visualizations, maybe someone else could try their hand at this one?
Clojure's refs are more complicated than Scala's actors, but Scala has no similar feature. If a Scala programmer needs the functionality in Clojure's refs, then the Scala programmer must use plain old Java concurrency.
Erlang is on my to-learn list, maybe that will change my opinion.
(I am currently updating my very rusty lisp (inspired by a comment on HN, btw). Gambit Scheme had some lib inspired by Erlang. I'll read that and maybe learn enough to have an opinion.)
How is this for reuse in Java? (And do note the "state" field...)
http://github.com/richhickey/clojure/blob/master/src/jvm/clo...