
15 Apr
2010
15 Apr
'10
4:55 a.m.
Hello Neil, Thursday, April 15, 2010, 12:37:35 PM, you wrote:
I find non-termination with a much simpler program than yours (GHC 6.12.1): forkIO $ do putStrLn "Started thread" forever $ return ()
ghc multithreading is actually cooperative: it switches only on memory allocation. since almost any haskell code allocates, there is no problem - it works like preemptive one. but sometimes this assumption fails - with optimization enabled, your code doesn't allocate so there are no chances for thread switching. replacing return () with threadDelay call solves the problem -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com