summaryrefslogtreecommitdiff
path: root/testsuite/tests/concurrent/should_run/conc037.hs
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/tests/concurrent/should_run/conc037.hs')
-rw-r--r--testsuite/tests/concurrent/should_run/conc037.hs27
1 files changed, 27 insertions, 0 deletions
diff --git a/testsuite/tests/concurrent/should_run/conc037.hs b/testsuite/tests/concurrent/should_run/conc037.hs
new file mode 100644
index 0000000000..7da76f5025
--- /dev/null
+++ b/testsuite/tests/concurrent/should_run/conc037.hs
@@ -0,0 +1,27 @@
+{-# OPTIONS_GHC -cpp #-}
+{-# LANGUAGE ForeignFunctionInterface #-}
+module Main where
+
+import Control.Concurrent
+
+#ifdef mingw32_HOST_OS
+foreign import stdcall safe "Sleep" _sleepBlock :: Int -> IO ()
+sleepBlock n = _sleepBlock (n*1000)
+#else
+foreign import ccall safe "sleep" sleepBlock :: Int -> IO ()
+#endif
+
+main :: IO ()
+main = do
+ th <- newEmptyMVar
+ forkIO $ do
+ putStrLn "newThread started"
+ sleepBlock 1
+ putStrLn "newThread back again"
+ putMVar th "1 sec later"
+ threadDelay 200000 -- make sure the newly created thread is run.
+ putStrLn "mainThread"
+ x <- takeMVar th
+ putStrLn x
+ putStrLn "\nshutting down"
+