Skip to content

Instantly share code, notes, and snippets.

@tuttlem
Created January 20, 2014 22:15
Show Gist options
  • Save tuttlem/8530352 to your computer and use it in GitHub Desktop.
Save tuttlem/8530352 to your computer and use it in GitHub Desktop.
fork1.hs
module Main where
import Control.Concurrent
main :: IO ()
main = do
-- grab the parent thread id and print it
parentId <- myThreadId
putStrLn (show parentId)
-- create a new thread (ignore the return)
_ <- forkIO $ do
-- grab the child thread id and print it
childId <- myThreadId
putStrLn (show childId)
return ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment