Loop thread hangs without `hFlush stdout` even there are no `print` things
问题 When I test some simple cases about threaded codes, I found some loop hang without hFlush stdout even it does not use any print things. import Control.Concurrent import System.IO import Data.IORef delay :: Int -> IO () delay = threadDelay . (* 1000000) wait sw = loop where loop = do v <- readIORef sw --hFlush stdout -- without this, hang if v then return() else loop monitor sw = forkIO $ loop where loop = do v <- readIORef sw print v delay 1 loop main = do sw <- newIORef False forkIO $ do