Junior — Middle
Kui palju virnu võib samaaegselt olla gorutinal?
sobes.tech AI
Vastus AI-lt
Go's goroutines have a dynamically expanding stack, which is initially very small — usually around 2 KB. The maximum stack size is not fixed and is limited only by available memory and runtime environment settings.
Thus, each goroutine has its own stack, but its size can grow as needed. This allows running thousands or even millions of goroutines simultaneously, since the initial stack size is very small.
Example:
func main() {
go func() {
// goroutine with a small stack
}()
}