summaryrefslogtreecommitdiff
path: root/testsuite/tests/concurrent/should_run/throwto002.hs
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/tests/concurrent/should_run/throwto002.hs')
-rw-r--r--testsuite/tests/concurrent/should_run/throwto002.hs25
1 files changed, 25 insertions, 0 deletions
diff --git a/testsuite/tests/concurrent/should_run/throwto002.hs b/testsuite/tests/concurrent/should_run/throwto002.hs
new file mode 100644
index 0000000000..c9857f1f1e
--- /dev/null
+++ b/testsuite/tests/concurrent/should_run/throwto002.hs
@@ -0,0 +1,25 @@
+{-# LANGUAGE DoRec, ScopedTypeVariables #-}
+import Control.Concurrent
+import Control.Exception
+import Data.Array
+import System.Random
+import System.Environment
+import Control.Monad
+import GHC.Conc
+import Data.IORef
+import Prelude hiding (catch)
+
+main = do
+ r <- newIORef 0
+ rec
+ t1 <- block $ forkIO (thread r t2)
+ t2 <- block $ forkIO (thread r t1)
+ threadDelay 1000000
+ readIORef r >>= print
+
+thread r t = run
+ where
+ run = (unblock $ forever $ do killThread t
+ i <- atomicModifyIORef r (\i -> (i + 1, i))
+ evaluate i)
+ `catch` \(e::SomeException) -> run