Deadlocks, Livelocks, and Starvation
Deadlocks
package main
import (
"fmt"
"sync"
)
func main() {
var wg sync.WaitGroup
ch1 := make(chan int)
ch2 := make(chan int)
wg.Add(1)
go func() {
defer wg.Done()
// Attempting to send data to ch2, but no one is receiving.
ch2 <- 42
}()
wg.Add(1)
go func() {
defer wg.Done()
// Attempting to send data to ch1, but no one is receiving.
ch1 <- 23
}()
wg.Wait()
}Livelocks
Starvation
Last updated