Concurrency is really hard part of programming. Recent time goroutine is very popular. My question is - What kind of goroutine analogues exist in other languages?
A goroutine is a function that executes simultaneously with other goroutines in a program and are lightweight threads managed by Go. A goroutine takes about 2kB of stack space to initialize.
Goroutines are extremely cheap when compared to threads. They are only a few kb in stack size and the stack can grow and shrink according to needs of the application whereas in the case of threads the stack size has to be specified and is fixed. The Goroutines are multiplexed to fewer number of OS threads.
A goroutine is a function that runs independently of the function that started it. Sometimes Go developers explain a goroutine as a function that runs as if it were on its own thread. Channel is a pipeline for sending and receiving data. Think of it as a socket that runs inside your program.
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 are inspired by CSP (Communicating sequential processes), which is highly influential in the design of the occam programming language, and also influenced the design of programming languages such as Limbo, RaftLib, Go, and Crystal.
Note that goroutine are not without criticisms.
It differs from the Actor Model in that:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With