Skip to content

Latest commit

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Demonstrates recursive goroutine spawning in Go, forming a depth-limited concurrent tree.

Configuration

  • Root goroutines: 3 (root-0, root-1, root-2)
  • Children per node: 3
  • Maximum depth: 3

Goroutine Tree

3 Roots (root-0, root-1, root-2)
│
├─→ Each spawns 3 children = 9 total at Depth 1
│ │
│ ├─→ Each spawns 3 children = 27 total at Depth 2
│ │ │
│ │ ├─→ Each spawns 3 children = 81 total at Depth 3
│ │ │ │
│ │ │ └─→ 81 Leaf nodes (no further spawning)

Tree:

  • 3 roots (root-0, root-1, root-2) - each follows the same branching pattern
  • 9 goroutines spawned at depth 1 (3 roots × 3 children each)
  • 27 goroutines spawned at depth 2 (9 parents × 3 children each)
  • 81 goroutines spawned at depth 3 (27 parents × 3 children each)
  • 81 leaf nodes at depth 3 (these don't spawn any children)

So Total = 9 + 27 + 81 = 117 goroutines spawned

How to run

go run main.go

The program will show each goroutine starting, spawning children, and completing. At the end, it displays the total number of goroutines spawned.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages