Open In App
Related Articles

Golang | Goroutine vs Thread

Improve Article
Save Article
Like Article

Goroutine: A Goroutine is a function or method which executes independently and simultaneously in connection with any other Goroutines present in your program. Or in other words, every concurrently executing activity in Go language is known as a Goroutines

Thread: A process is a part of an operating system which is responsible for executing an application. Every program that executes on your system is a process and to run the code inside the application a process uses a term known as a thread. A thread is a lightweight process, or in other words, a thread is a unit which executes the code under the program. So every program has logic and a thread is responsible for executing this logic. 

Here are some of the differences between Goroutine and Thread:

Goroutine Thread
Goroutines are managed by the go runtime. Operating system threads are managed by kernel.
Goroutine are not hardware dependent. Threads are hardware dependent.
Goroutines have easy communication medium known as channel. Thread does not have easy communication medium.
Due to the presence of channel one goroutine can communicate with other goroutine with low latency. Due to lack of easy communication medium inter-threads communicate takes place with high latency.
Goroutine does not have ID because go does not have Thread Local Storage. Threads have their own unique ID because they have Thread Local Storage.
Goroutines are cheaper than threads. The cost of threads are higher than goroutine.
They are cooperatively scheduled. They are preemptively scheduled.
They have faster startup time than threads. They have slow startup time than goroutines.
Goroutine has growable segmented stacks. Threads does not have growable segmented stacks.
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 14 Mar, 2023
Like Article
Save Article
Similar Reads