[Haskell-cafe] forkIO on GHCI does not seem to spawn the thread in the background on some OSs

David Leimbach leimy2k at gmail.com
Tue Feb 8 15:07:39 CET 2011


On Monday, February 7, 2011, C K Kashyap <ckkashyap at gmail.com> wrote:
> Hi,I found that on windows and my ubuntu box, when I did this
> ghci> t <- forkIO someAction
> "someAction" started executing in the foreground - as in, the ghci prompt did not come back (until I pressed Ctrl-C)
>
> On my mac however, when I ran the same thing, the action started executing in the background and ghci> prompt returned instantaneously.How can I get the thread backgrounded explicitly?

It is not always a thread.  ForkIO creates a spark and then the
scheduler decides when sparks should be scheduled to threads.  Thus
you get a guarantee of concurrent but not parallel execution.

Are you running with threads enabled?

>
> Regards,Kashyap
>



More information about the Haskell-Cafe mailing list