goroutines-async-channel-send-receive-waiting

command
v0.0.0-...-a2a1f02 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 1, 2020 License: MIT Imports: 2 Imported by: 0

README

goroutines-async-channel-send-receive-waiting example

Sending data to a goroutine via an async channel. Both SEND and RCV will block/wait for data.

These are my 5 main example of using goroutines,

GitHub Webpage

CHANNELS (MESSAGE PASSING)

Giving a channel msgCh,

Send,

msgCh <- "Jeff"                             // WAITS/BLOCKS

Receive,

say = <-msgCh                               // ALSO WAITS/BLOCKS

IMAGE - goroutines-async-channel-send-receive-waiting - IMAGE

RUN

go run goroutines-async-channel-send-receive-waiting.go

Simply press return to exit.

Output is always,

Sent message Jeff
                             0 Received message Jeff
Sent message Clif
                             1 Received message Clif
Sent message Jack
                             2 Received message Jack
Sent message Jill
                             3 Received message Jill

Try slowing down or speeding up the SEND or RCV and you will always get the same result because both sides block/wait.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL