On Wed, Apr 8, 2020 at 10:17 AM <aravindhank1...@gmail.com> wrote:
>
>
> Hi All,
>
> I am not able to understand why this piece of go code  deadlocks.
> Doesn't empty select{} blocks forever, irrespective of other go routines  to 
> wake that up.
>
> https://play.golang.org/p/zBWZPjTGYX7
>
> Please help me to understand why code is detected as deadlock.

There is one goroutine, the main one, waiting on a select and there
are no other goroutines that can do anything to let that goroutine
progress. That's a deadlock. If the other goroutines were in a loop
sending-receiving messages, it wouldn't be a deadlock.

> And When I run this code with go run -race main.go in Linux box(go version 
> go1.13.6 linux/amd64), it prints "received 5" waits forever.
> I expect same to happen, when built and run.
>
> Sorry, if this is already answered, please point me.
>
> Thanks ,
> Aravindhan K
>
> --
> You received this message because you are subscribed to the Google Groups 
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/5eeffc06-15e6-47d8-a662-43746f2e8fe5%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAMV2RqoVjP%3DmTvtWsE_hhQR7W_SNQ9-dAb5teJrSRSXsXuHxcQ%40mail.gmail.com.

Reply via email to