Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

Concurrency Primer: Gorouti | Go Programming Bootcamp lesson | BraveProgrammer
  1. Courses
  2. /
  3. Go Programming Bootcamp

Lesson 13 of 60

·Go

Concurrency Primer: Goroutines

20 minutes

Course progress22%

Goroutines

This lesson explains the main concept clearly with beginner-friendly examples and background so you can learn why the code works.

A goroutine is a lightweight thread managed by the Go runtime.

func say(msg string) {
    for i := 0; i < ; i++ {
        fmt.Println(msg)
    }
}

 {
     say() 
    say()    
}
3
func main()
go
"world"
// runs concurrently
"hello"
// runs in main goroutine

Scheduling

  • The runtime multiplexes many goroutines onto a small set of OS threads.
  • The default GOMAXPROCS is the number of logical CPUs.

Synchronizing with sync.WaitGroup

var wg sync.WaitGroup
for i := 0; i < 5; i++ {
    wg.Add(1)
    go func(id int) {
        defer wg.Done()
        fmt.Println("worker", id)
    }(i)
}
wg.Wait()

Info

Never block a goroutine with a long‑running OS call without releasing the CPU (use runtime.Gosched).
Make it stickPractice what you've learned1 quiz · 3 practical tests · Optional activities from Go Programming BootcampBrowse activities
Previous lessonBenchmarking & ProfilingContinue to lesson 14Channels: Communication Between GoroutinesBack to Go Programming Bootcamp curriculum