summaryrefslogtreecommitdiff
path: root/testsuite/tests/concurrent/should_run/throwto003.hs
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/tests/concurrent/should_run/throwto003.hs')
-rw-r--r--testsuite/tests/concurrent/should_run/throwto003.hs17
1 files changed, 17 insertions, 0 deletions
diff --git a/testsuite/tests/concurrent/should_run/throwto003.hs b/testsuite/tests/concurrent/should_run/throwto003.hs
new file mode 100644
index 0000000000..6369c62352
--- /dev/null
+++ b/testsuite/tests/concurrent/should_run/throwto003.hs
@@ -0,0 +1,17 @@
+{-# LANGUAGE DoRec, ScopedTypeVariables #-}
+import Control.Concurrent
+import Control.Exception
+import Control.Monad
+import Prelude hiding (catch)
+
+main = do
+ m <- newMVar 1
+ t1 <- forkIO $ thread m
+ t2 <- forkIO $ forever $ killThread t1
+ threadDelay 1000000
+ takeMVar m
+
+thread m = run
+ where
+ run = (unblock $ forever $ modifyMVar_ m $ \v -> if v `mod` 2 == 1 then return (v*2) else return (v-1))
+ `catch` \(e::SomeException) -> run