Skip to content

Instantly share code, notes, and snippets.

@tuttlem
Created March 19, 2014 04:49
Show Gist options
  • Save tuttlem/9635578 to your computer and use it in GitHub Desktop.
Save tuttlem/9635578 to your computer and use it in GitHub Desktop.
MVar example
import Control.Concurrent
import Control.Concurrent.MVar
main :: IO ()
main = do
-- create an empty mvar
m <- newEmptyMVar
-- get another thread to put a value in it
forkIO $ putMVar m "A value"
-- take the value
x <- takeMVar m
putStrLn x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment