[Haskell-cafe] Re: Cleaning up threads

Edward Z. Yang ezyang at MIT.EDU
Tue Sep 14 14:21:50 EDT 2010


Excerpts from Ertugrul Soeylemez's message of Mon Sep 13 03:03:11 -0400 2010:
> In general it's better to avoid using killThread.  There are much
> cleaner ways to tell a thread to exit. 

This advice doesn't really apply to Haskell: in fact, the GHC developers
have thought really carefully about this:

    http://research.microsoft.com/en-us/um/people/simonpj/papers/asynch-exns.ps.gz

Pure code can always be safely asynchronously interrupted (even code
using state like the ST monad), and IO code can be made to interact
correctly with thread termination simply by using appropriate bracketing
functions that would handle normal IO exceptions.

Edward


More information about the Haskell-Cafe mailing list