import Control.Concurrent
main = do
forkIO $ putStrLn "123"
forkIO $ putStrLn "456"
I have written the code above. But when I executed it, I always got 123
only. 456
is not printed. I guess it is because main thread ended before the other thread so the whole program just ended.
How can I prevent this? Any api can make sure main thread ended after all threads ended?
OS: OS X 10.8.3
compiler: ghc 7.4.2