Created
July 25, 2015 08:37
-
-
Save rightfold/4d5cb030c06884e921e5 to your computer and use it in GitHub Desktop.
This file contains 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
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