[Haskell-cafe] Threads freezing

nccb2 at kent.ac.uk nccb2 at kent.ac.uk
Sun Apr 25 10:53:34 EDT 2010

> Hello fellow Haskell programmers,
> I seem to be having problems with some threads of mine. I wrote an
> OpenGL program that employs some threads (forkIO) in order to separate
> any calculations from the OpenGL code. At first it all seemed to be
> working just fine. Then I added some code for keyboard input to reset
> the program when you press 'r'. Since then my threads have been giving
> me problems. Just a second after the program starts all the calculations
> stop. The program is still running the code to display graphics (I
> tested this by putting "putStrLn "still displaying" into the display
> function) but the threads that do all of the computation don't seem to
> return from their threadDelay, which is only a delay of 5000
> microseconds. I tried getting rid of the code for keyboard input but the
> problem is still there. I tried to run the program on another computer
> and it ran just fine (without keyboard input). Does anyone have any idea
> what could be going on?
> Additionally, I just tried compiling it to an executable and it seems
> that when I run it from that it works fine, with the keyboard input too.
> So I'm guessing the problem is with the interpreter? I'm not really
> sure. Haskell is still pretty mysterious to me.


Are you using the -threaded flag?  This should be given to ghc when
compiling, and I guess also to ghci when interpreting.  A few more details
are on this page
if you scroll down to find -threaded.  I guess it's probably the OpenGL
calls that trigger the issue, although I had a feeling threadDelay can
sometimes be problematic without -threaded.



More information about the Haskell-Cafe mailing list