Guia Prático de Concorrência em Go
Planejamento de Tarefas
sync.WaitGroup
package main
import (
"fmt"
"sync"
)
// Exemplo de uso de goroutines
func imprimirMensagem() {
fmt.Println("Goroutine executada")
}
var grupo sync.WaitGroup
func tarefaWaitGroup(id int) {
defer grupo.Done()
fmt.Println(id, "tarefa concluída")
}
func main() ...
Publicado em 6-2 05:03 por Thomas