I would say that the biggest difference is that Go channels support the select statement, which allows you to perform exactly one operation on the channel. Example (modified from Go language specification ):
select { case i1 = <-c1: print("received ", i1, " from c1\n") case c2 <- i2: print("sent ", i2, " to c2\n") case i3, ok := (<-c3): // same as: i3, ok := <-c3 if ok { print("received ", i3, " from c3\n") } else { print("c3 is closed\n") } }
In this example, only one of the receive-from-c1, send-c2, or receive-c-c3 operations will be performed. When you enter a selection, an arbitrary channel is selected (if any). Otherwise, the operation is blocked until one of the channels is ready.
I am not aware of any trivial way of modeling the selection of this channel using the Java utility. It can be argued that this is a property of the select statement, not a channel design, but I would say that it is fundamental to channel design.
Bret kail
source share