IMHO this program should not print "Fail: thread killed". Removing
the first threadDelay causes the message to disappear. It can be
worked around by catching the exception in the thread to be killed.

import Concurrent

kill:: IO ()
kill = do
    result   <- newEmptyMVar
    finished <- newMVar ()
    t1 <- forkIO $ do
        threadDelay 1
        takeMVar finished
        putMVar result ()
    t2 <- forkIO $ do
        threadDelay 1000000
        takeMVar finished
        putMVar result ()
    takeMVar result
    killThread t2

main:: IO ()
main = kill >> kill

-- 
 __("<    Marcin Kowalczyk * [EMAIL PROTECTED] http://qrczak.ids.net.pl/
 \__/              GCS/M d- s+:-- a22 C+++$ UL++>++++$ P+++ L++>++++$ E-
  ^^                  W++ N+++ o? K? w(---) O? M- V? PS-- PE++ Y? PGP+ t
QRCZAK                  5? X- R tv-- b+>++ DI D- G+ e>++++ h! r--%>++ y-

Reply via email to