[Haskell-beginners] Re: threadDelay does not delay thread execution?

Benjamin Edwards edwards.benj at gmail.com
Mon Jul 5 06:41:03 EDT 2010


ahhhh.... I had read mirco secords, but for some reason in my addled brain I
converted that to miliseconds. Doh!

Thans

On 5 July 2010 12:34, Ertugrul Soeylemez <es at ertes.de> wrote:

> Benjamin Edwards <edwards.benj at gmail.com> wrote:
>
> > 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?
>
> Note that threadDelay takes microseconds, not milliseconds.  So
> 'threadDelay 1000000' should wait one second (at least).
>
>
> Greets,
> Ertugrul
>
>
> --
> nightmare = unsafePerformIO (getWrongWife >>= sex)
> http://ertes.de/
>
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20100705/066d0559/attachment.html


More information about the Beginners mailing list