Created
February 27, 2011 23:52
-
-
Save jkutner/846707 to your computer and use it in GitHub Desktop.
simple example of Akka STM in Java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
new Atomic<Void>() { | |
public Void atomically() { | |
ref.set(refs.get() + 1); | |
return null; | |
} | |
}.execute(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Class.new(Atomic) do | |
def init(ref) | |
@ref = ref | |
self | |
end | |
def atomically | |
@ref.set(@ref.get + 1) | |
end | |
end.new.init(ref).execute |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment