Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

multi-thread example

package main


import "fmt"



func main() {
c := make(chan int) // Allocate a channel.
// Start the sort in a goroutine; when it completes, signal on the channel.
go func() {
    for x:=0 ; x<20 ;x++{
        fmt.Println("x=",x)
    }
    c <- 1  // Send a signal; value does not matter.
}()
//<-c // Wait for sort to finish; discard sent value.
for y:=0 ; y<40 ; y++{
    fmt.Println("y=",y)

}

 
}

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.