(Most asked Golang concurrency questions and answers)

Deadlock — everyone is waiting, nobody can proceed. Goroutines block forever waiting for each other. No progress is possible.

Livelock — everyone is running, but no progress is made. Goroutines are active (not blocked) but keep stepping out of each other’s way, doing work that prevents progress.

Starvation — one goroutine never gets CPU or data. One goroutine is ready to run, but other goroutines or scheduling policies prevent it from running.

Race Condition — outcome depends on timing. Multiple goroutines access shared data without proper synchronization → final result is nondeterministic.

Blocking — goroutine waits, but may eventually continue. A goroutine is temporarily stuck (waiting for I/O, lock, channel), but will proceed eventually.

EASY – Warm-up (Junior/Mid-level)

1. What is a goroutine, and how do you create one?

A goroutine is a lightweight thread managed by the Go runtime (not the operating system).

Key characteristics of goroutines:

package main

import (
	“fmt”
	”time”
)

func hello() {
	fmt.Println(”Hello world”)
}

func main(){
	go hello() // launches a new goroutine, using go keyword
	time.Sleep(1*time.Second) // main must wait, if not goroutine doesn’t work
}

// Output: Hello world

2. What is the difference between concurrency and parallelism in Go?