Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Glasgow Haskell Compiler
GHC
Commits
73c48a99
Commit
73c48a99
authored
May 07, 1999
by
simonm
Browse files
[project @ 1999-05-07 11:16:37 by simonm]
Ignore exceptions in the spawned threads.
parent
65c6e0da
Changes
1
Hide whitespace changes
Inline
Side-by-side
ghc/tests/concurrent/should_run/conc007.hs
View file @
73c48a99
...
...
@@ -3,19 +3,27 @@
module
Main
where
import
Concurrent
import
Exception
import
IOExts
choose
::
a
->
a
->
IO
a
choose
a
b
=
do
ready
<-
newMVar
()
answer
<-
newEmptyMVar
a_id
<-
f
orkIO
(
a
`
seq
`
takeMVar
ready
>>
putMVar
answer
a
)
b_id
<-
f
orkIO
(
b
`
seq
`
takeMVar
ready
>>
putMVar
answer
b
)
a_id
<-
myF
orkIO
(
a
`
seq
`
takeMVar
ready
>>
putMVar
answer
a
)
b_id
<-
myF
orkIO
(
b
`
seq
`
takeMVar
ready
>>
putMVar
answer
b
)
it
<-
takeMVar
answer
killThread
a_id
killThread
b_id
return
it
-- We need to catch the exception raised by killThread and ignore it.
-- Otherwise the default handler will exit the program when this
-- exception is raised in any thread.
myForkIO
::
IO
()
->
IO
ThreadId
myForkIO
io
=
forkIO
(
catchAllIO
io
(
\
e
->
return
()
))
main
=
do
let
big
=
sum
[
1
..
]
small
=
sum
[
1
..
42
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment