Hi All,

I am looking to make a simple program that polls an interface once a second or so. I thought  I could use threadDelay for this, so knocked up the following toy program to test my idea.

module TD
  where
 
import Control.Concurrent
import Control.Concurrent.MVar

main :: IO ()
main = do mv <- newEmptyMVar
          forkIO $ loop mv 0 "Hai"
          takeMVar mv
          return ()
  where loop mv n msg = do putStrLn msg
                           threadDelay 10000
                           if n < 10 then loop mv (n+1) msg
                                     else putMVar mv ()

It doesn't work, in as much as I see all the messages printed seemingly as fast as Std out will print them. What am I doing wrong?

All help is much appreciated,
Ben