Skip to content

Instantly share code, notes, and snippets.

@havenwood
Last active December 17, 2015 18:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save havenwood/5654484 to your computer and use it in GitHub Desktop.
Save havenwood/5654484 to your computer and use it in GitHub Desktop.
Clojure STM in JRuby
##
# First clone the clojure repo and cd in to the directory:
#
# git clone git@github.com:clojure/clojure.git
# cd clojure
#
require 'clojure.jar'
java_import 'clojure.lang.Ref'
java_import 'clojure.lang.LockingTransaction'
ref = Ref.new 1
ref.current_val
#=> 1
LockingTransaction.run_in_transaction do
ref.set 10
end
ref.current_val
#=> 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment