Go WaitGroup

From NovaOrdis Knowledge Base
Revision as of 21:15, 1 September 2023 by Ovidiu (talk | contribs) (→‎Overview)
Jump to navigation Jump to search

External

Internal

Overview

A WaitGroup is a counting semaphore that waits for a set of goroutines to finish. The main goroutine calls Add() to set the number of goroutines to wait for. When each of the counted goroutines runs, they should call Done() when finished. At the same time, the main goroutine blocks on Wait() until all other goroutines have finished.