0 votes
in GoLang by
What is goroutine in Go programming language?

1 Answer

0 votes
by

A goroutine is a function which usually runs concurrently with other functions. If you want to stop goroutine, you pass a signal channel to the goroutine, that signal channel pushes a value into when you want the goroutine to stop.

The goroutine polls that channel regularly as soon as it detects a signal, it quits.

Quit : = make (chan bool)  

go func ( ) {  

for  {  

select {  

case <- quit:  

return  

default  

// do other stuff  

}  

}  

}()  

// Do stuff  

// Quit goroutine  

Quit <- true  

Related questions

0 votes
asked Aug 19, 2022 in GoLang by john ganales
0 votes
asked Aug 19, 2022 in GoLang by john ganales
...