HORIZON HASKELLDocslts/ghc-9.14.x7a6c33e2026-10-12Search packagesCtrl K
Theme: |

GHC 9.14.1 · lts/ghc-9.14.x · 7a6c33e · 2026-10-12

Modulethreads-0.5.1.8Haskell2010

Control.Concurrent.Thread.Group

This module extends Control.Concurrent.Thread with the ability to wait for a group of threads to terminate.

This module exports equivalently named functions from Control.Concurrent, (GHC.Conc), and Control.Concurrent.Thread. Avoid ambiguities by importing this module qualified. May we suggest:

import Control.Concurrent.Thread.Group ( ThreadGroup )
import qualified Control.Concurrent.Thread.Group as ThreadGroup ( ... )
Contents
  1. Forking threads
Synopsis
  • Packagethreads-0.5.1.8
  • Exports10
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceGroup.hs
newtypenewtype ThreadGroup

A ThreadGroup can be understood as a counter which counts the number of threads that were added to the group minus the ones that have terminated.

More formally a ThreadGroup has the following semantics:

  • new initializes the counter to 0.

  • Forking a thread increments the counter.

  • When a forked thread terminates, whether normally or by raising an exception, the counter is decremented.

  • nrOfRunning yields a transaction that returns the counter.

  • wait blocks as long as the counter is greater than 0.

  • waitN blocks as long as the counter is greater or equal to the specified number.

Instances1Eq
  • Eq ThreadGroupDefined in threads-0.5.1.8 · Control.Concurrent.Thread.Group

Yield a transaction that returns the number of running threads in the group.

Note that because this function yields a STM computation, the returned number is guaranteed to be consistent inside the transaction.

Forking threads