Create goroutines

suggest change

Any function can be invoked as a goroutine by prefixing its invocation with the keyword go:

func mult(x, y int) {
	fmt.Printf("%d * %d = %d\n", x, y, x*y)
}

	go mult(1, 2) // first execution, non-blocking
	go mult(3, 4) // second execution, also non-blocking
1 * 2 = 2
3 * 4 = 12

A go statement does not use the function's results. mult returns nothing; if it returned a value, that value would be discarded.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents