Commit 13b37f4f authored by sof's avatar sof
Browse files

[project @ 2002-04-15 17:57:23 by sof]

call-in/call-back MT test
parent 729463bb
......@@ -48,3 +48,4 @@ test "conc034" { myvtr("", "+RTS -C0 -RTS", "") }
test "conc035" { myvtr("", "", "") }
test "conc036" { myvtr("", "", "") }
test "conc037" { myvtr("", "", "") }
test "conc038" { myvtr("", "", "") }
module Main where
import Control.Concurrent
haskellFun :: Int -> IO ()
haskellFun c = putStrLn ("Haskell: " ++ show c)
foreign export "hFun" haskellFun :: Int -> IO ()
foreign import "hFun" threadsafe hFun :: Int -> IO ()
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.
forkIO $ (hFun 2)
putStrLn "mainThread"
x <- takeMVar th
putStrLn x
putStrLn "\nshutting down"
newThread started
mainThread
Haskell: 2
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