Go (golang) Tutorials - Buffered Channels

Published: 14 April 2018
on channel: Ambasoft Java
1,735
25

#golang #go #concurrency #channels

Concurrency - Buffered Channels
--------------------------------
= Similar to regular channels but they have some buffer size to store values
= The channel send operations will remain un blocking until the buffer slots are available
= Once the buffer slots got filled up, then the send channels will be blocking as usual

bufdemo.go
-----------
package main
import "fmt"
func main(){
//There is no wait/sleep operation in main go routine
channel:=make(chan int, 2) //Create a buffered channel of capacity 2
channel(arrow operator)10 //Sending two values to the channel
channel(arrow operator)20
//channel(arrow operator)30
fmt.Printf("%d\n",len(channel))
fmt.Printf("%d\n",(arrow operator)channel)
fmt.Printf("%d\n",len(channel))
fmt.Printf("%d\n",(arrow operator)channel) //Receiving two values from the channel
fmt.Printf("%d\n",cap(channel))
}


Watch video Go (golang) Tutorials - Buffered Channels online, duration hours minute second in high quality that is uploaded to the channel Ambasoft Java 14 April 2018. Share the link to the video on social media so that your subscribers and friends will also watch this video. This video clip has been viewed 1,735 times and liked it 25 visitors.