Commit 3440ce38 authored by sof's avatar sof
Browse files

[project @ 2002-04-13 05:11:29 by sof]

testing MT extension
parent 7967fced
module Main where
import Control.Concurrent
foreign import "sleep" unsafe sleepBlock :: Int -> IO ()
main :: IO ()
main = do
th <- newEmptyMVar
forkIO $ do
putStrLn "newThread started"
sleepBlock 5
putStrLn "newThread back again"
putMVar th "5 secs later"
yield -- make sure the newly created thread is run.
putStrLn "mainThread"
x <- takeMVar th
putStrLn x
putStrLn "\nshutting down"
newThread started
newThread back again
mainThread
5 secs later
shutting down
module Main where
import Control.Concurrent
foreign import "sleep" threadsafe sleepBlock :: Int -> IO ()
main :: IO ()
main = do
th <- newEmptyMVar
forkIO $ do
putStrLn "newThread started"
sleepBlock 5
putStrLn "newThread back again"
putMVar th "5 secs later"
yield -- make sure the newly created thread is run.
putStrLn "mainThread"
x <- takeMVar th
putStrLn x
putStrLn "\nshutting down"
newThread started
mainThread
newThread back again
5 secs later
shutting down
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment