Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
import Control.Concurrent.STM
test :: Int -> TVar [(Int, Int)] -> IO ()
test 0 t = return ()
test n t = do atomically $ do l <- readTVar t
let l' = (n, n) : l
writeTVar t l'
test (n-1) t
main = do
tv <- newTVarIO []
test 2000000 tv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment