---
source: https://iinventedlight.com/library/notes/go-sync-cond.md
title: "sync.Cond: wait until a condition is announced"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "BSD-3-Clause (Go); BSD-3-Clause (Go); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: Go, sync package reference; Go, sync/cond.go source. BSD-3-Clause (https://go.dev/LICENSE). Copyright The Go Authors."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-23
status: published
approved_by: "Cole Withington, 2026-11-27 14:30 PT: \"Yes, publish all of that now\""
checked_on: 2026-11-23
as_of: 2026-11-23
confidence: medium
untested: "Not reproduced (2026-11-23). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-systems: go-sync-cond"
tags: [go, sync, cond, concurrency, mutex]
client: Librarian
sources:
  - id: S1
    title: "sync package reference"
    publisher: Go
    url: https://pkg.go.dev/sync
    accessed: 2026-11-23
    license: "BSD-3-Clause"
  - id: S2
    title: "sync/cond.go source"
    publisher: Go
    url: https://go.dev/src/sync/cond.go
    accessed: 2026-11-23
    license: "BSD-3-Clause"
---
# sync.Cond: wait until a condition is announced
**Answer:** Cond is a condition variable: goroutines meet there to wait for an event or to announce one. Each Cond has a Locker L. The Locker L must be held when changing the condition and when calling Wait. Wait unlocks, suspends, and locks again. Signal wakes one goroutine. Broadcast wakes all.

## Wait, Signal, and Broadcast

NewCond builds a Cond from a Locker.

Wait atomically unlocks c.L and suspends the calling goroutine.

After it resumes, Wait locks c.L before it returns.

In Go, Wait returns only after Signal or Broadcast wakes it.

c.L is not locked during the wait, so the caller typically cannot assume the condition is true when Wait returns.

The caller should Wait in a loop.

Broadcast wakes every goroutine waiting on c. Signal wakes one, if any is waiting.

The caller may hold c.L during Signal or Broadcast, but does not have to.

## The associated locker, and a caution

Cond implements a condition variable, a rendezvous point for goroutines waiting for or announcing an event.

The associated Locker, often a Mutex or RWMutex, must be held when the condition changes and when Wait is called.

Do not copy a Cond after you first use it.

For simple cases, a channel is often a better tool than a Cond.

## See also

- [go-sync-mutex](https://iinventedlight.com/library/notes/go-sync-mutex/)
- [go-channels](https://iinventedlight.com/library/notes/go-channels/)
- [go-sync-waitgroup](https://iinventedlight.com/library/notes/go-sync-waitgroup/)

## Claims

- id: C1
  claim: NewCond builds a Cond from a Locker.
  source: S1
  evidence: "returns a new Cond with Locker"

- id: C2
  claim: Wait unlocks the locker and suspends the caller.
  source: S1
  evidence: "atomically unlocks c.L and suspends execution"

- id: C3
  claim: Wait does not return unless Signal or Broadcast wakes it.
  source: S1
  evidence: "cannot return unless awoken by"

- id: C4
  claim: Broadcast wakes every waiting goroutine.
  source: S1
  evidence: "wakes all goroutines waiting on c"

- id: C5
  claim: A Cond is a rendezvous point for waiting or announcing an event.
  source: S2
  evidence: "rendezvous point"

- id: C6
  claim: The associated locker must be held when changing the condition and when calling Wait.
  source: S2
  evidence: "must be held when changing the condition"

- id: C7
  claim: A Cond must not be copied after first use.
  source: S2
  evidence: "must not be copied after first use"

## Sources

- [S1] sync package reference. Go. https://pkg.go.dev/sync . License: BSD-3-Clause. Accessed 2026-11-23.

- [S2] sync/cond.go source. Go. https://go.dev/src/sync/cond.go . License: BSD-3-Clause. Accessed 2026-11-23.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Go, sync package reference; Go, sync/cond.go source. BSD-3-Clause (https://go.dev/LICENSE). Copyright The Go Authors. Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
