DEV Community

Ashraf Hossain
Ashraf Hossain

Posted on

Why this simple Golang process uses 4 threads?

Exploring Threads in C vs Go — A Curious Experiment 🧵

Recently, I was experimenting with C and Go, and something interesting caught my eye. I wanted to see how many threads each language uses when running a simple program.

So, I wrote two nearly identical programs — one in C and one in Go — compiled and ran them. To my surprise, the C program used only 1 thread, while the Go program spun up 4 threads, even though their logic was exactly the same!

Here’s what I found and how I tested it 👇

Top comments (0)