Re: [go-nuts] Re: Why a single go routine with sleep is using 100% cpu (1 core)

2016-09-11 Thread Ilya Kostarev
On 09/12/2016 03:01 AM, Sagar P. wrote: Ah, I see my mistake. Removed default to avoid a busy-loop. Thanks! Without `default` you need hot `for` and `select` at all. Just _ = <-channel: fmt.Println("Go routine has ended") os.Exit(0) would be enough. In real situations however

[go-nuts] Re: Why a single go routine with sleep is using 100% cpu (1 core)

2016-09-11 Thread Sagar P.
Ah, I see my mistake. Removed default to avoid a busy-loop. Thanks! On Sunday, September 11, 2016 at 4:11:26 PM UTC-7, Sagar P. wrote: > > go version > go version go1.6.3 linux/amd64 > > uname -r > 3.13.0-95-generic > > Below code is using 100% cpu (1 full core) > > package main > > import ( >