Skip to content

Instantly share code, notes, and snippets.

@DeTeam
Created August 25, 2012 19:45
Show Gist options
  • Save DeTeam/3470119 to your computer and use it in GitHub Desktop.
Save DeTeam/3470119 to your computer and use it in GitHub Desktop.
import Control.Concurrent
import Control.Concurrent.Async
import System.Random
delayedOutput :: String -> IO ()
delayedOutput m = do
gen <- newStdGen
let (t, _) = randomR (1, 10) ge
-- delay in microseconds
threadDelay (t * 1000000)
-- display message
putStrLn m
return ()
main :: IO ()
main = do
putStrLn "Fight!"
a <- async (delayedOutput "Finish him!")
wait a
return ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment