Skip to content

Instantly share code, notes, and snippets.

@rightfold
Created July 25, 2015 08:37
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 rightfold/4d5cb030c06884e921e5 to your computer and use it in GitHub Desktop.
Save rightfold/4d5cb030c06884e921e5 to your computer and use it in GitHub Desktop.
do
balanceA <- newTVarIO (400 :: Int)
balanceB <- newTVarIO (900 :: Int)
replicateM_ 100 . forkIO $ do
atomically $ do
modifyTVar balanceA (\x -> x + 2)
modifyTVar balanceB (\x -> x - 2)
readTVarIO balanceA >>= print
readTVarIO balanceB >>= print
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment