“Pergi goroutine” Kode Jawaban

Goroutine

// just a function (which can be later started as a goroutine)
func doStuff(s string) {
}

func main() {
    // using a named function in a goroutine
    go doStuff("foobar")

    // using an anonymous inner function in a goroutine
    go func (x int) {
        // function body goes here
    }(42)
}
DevLorenzo

Pergi goroutine

package main
import (
  "fmt"
  "time"
)

// creating a function
func display(message string) {

  fmt.Println(message)
}

func main() {

  // calling goroutine
  go display("Process 1")

  display("Process 2")
}
SAMER SAEID

Jawaban yang mirip dengan “Pergi goroutine”

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya