Commit dab0c2ed authored by simonmar's avatar simonmar
Browse files

[project @ 2005-05-13 08:15:50 by simonmar]

make this test slightly more robust
parent 948e39c2
module Main where
import Control.Concurrent
import Control.Exception
import Prelude hiding (catch)
import Foreign
import System.IO
foreign import "sleep" unsafe sleepBlock :: Int -> IO ()
main :: IO ()
main = do
newStablePtr stdout -- prevent stdout being finalized, sigh
th <- newEmptyMVar
forkIO $ do
putStrLn "newThread started"
sleepBlock 3
putStrLn "newThread back again"
putMVar th "5 secs later"
threadDelay 1000000 >> putStrLn "mainThread"
sleepBlock 1
putMVar th "child"
threadDelay 500000 >> putMVar th "main" `catch` \_ -> return ()
-- tests that the other thread doing an unsafe call to
-- sleep(3) has blocked this thread. Not sure if this
-- is a useful test.
newThread started
newThread back again
5 secs later
shutting down
Supports Markdown
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