What is the method of realizing multi-core parallelization in go language channel
This article introduces the go language channel to achieve multi-core parallel operation method is how, the content is very detailed, interested friends can refer to, hope to be helpful to you.
An Add function is defined here, which is used to return the sum of two integers and parallelize the operation using the go statement. In order to wait for each parallel operation to finish and get its return value, channel needs to be introduced.
The code is as follows:
Package mainimport "fmt" func Add (x int,y int,channel chan int) {sum: = library.Add (xrecoy) fmt.Println (sum) channel