This code snippet shows how to use Clojure Atoms to implement thread safe instance variables in JRuby classes.

The atom_attr_accessor method is used analog to the usual attr_accessor so this should seem natural for the language, though I don't have enough experience with it to judge that.

Blog Logo

Fernando Ipar



Fernando Ipar

"Tell my wife I love her very much, she knows"

Back to Overview