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:
|Goroutines are managed by the go runtime.||Operating system threads are managed by kernal.|
|Goroutine are not hardware dependent.||Threads are hardware dependent.|
|Goroutines have easy communication medium known as channel.||Thread doesnot 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 doesnot have ID because go doesnot 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 fasted startup time than threads.||They have slow startup time than goroutines.|
|Goroutine has growable segmented stacks.||Threads doesnot have growable segmented stacks.|
- How to pause the execution of current Goroutine?
- Difference between User Level thread and Kernel Level thread
- Difference between Thread.start() and Thread.run() in Java
- Lock framework vs Thread synchronization in Java
- Difference between Process and Kernel Thread
- Difference between Process and User Level Thread
- Difference between Thread Context Switch and Process Context Switch
- Difference between Process Image and Multi Thread Process image
- Difference between Process and Thread
- How to convert a slice of bytes in uppercase in Golang?
- Golang program that uses fallthrough keyword
- math.Lgamma() Function in Golang with Examples
- math.Float64bits() Function in Golang With Examples
- How to check equality of slices of bytes in Golang?
- atomic.AddInt64() Function in Golang With Examples
- atomic.StoreInt64() Function in Golang With Examples
- reflect.FieldByIndex() Function in Golang with Examples
- string.Contains Function in Golang with Examples
- bits.Sub() Function in Golang with Examples
- How to convert a slice of bytes in lowercase in Golang?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : pradeepjangidcse15