JZTXT
  • 首页
  • Ai
  • Java
  • Python
  • Android
  • Mysql
  • JavaScript
  • Html
  • CSS

Goroutines example

发布时间 2023-05-03 11:29:27作者: bovyfly

一个入门的goroutines例子

package main

import (
    "fmt"
    "time"
)

func f(from string) {
    for i := 0; i < 3; i++ {
        fmt.Println(from, ":", i)
    }
}

func main() {

    f("direct")

    go f("goroutine")

    go func(msg string) {
        fmt.Println(msg)
    }("going")

    time.Sleep(time.Second)
    fmt.Println("done")
}
    本栏目推荐文章
  • Matlab plottting example
  • 【MITK框架】如何在BlueBerry Example Launcher中添加入口选项
  • 鸿蒙开发 ERROR: Failed to find the incremental input file: C:\Users\admin\.ohos\config\auto_debug_MyApplication2_com.example.myapplication2_2850086000448618441.cer.
  • Applied Statistics - 应用统计学习 - numpy array交换两行 ? How to Swap Two Rows in a NumPy Array (With Example)
  • sqlite example
  • Dependency injection framework -- Decoupled packages example (multiple containers) -- ADD DIP IMPROVEMENT
  • 记Redux下载后,运行examples/todos时,报错Error: error:0308010C:digital envelope routines::unsupported 和 Failed to load config "react-app" to extend from.
  • Beyond Hello World, A Computer Vision Example
  • [Script][2d_poly_examples][2D Polygon - Simulation Object]
  • 【问题记录】【IDEA工具】升级了个版本- -启动报错 com.intellij.ide.util.PropertiesComponentImpl PluginClassLoader(plugin=PluginDescriptor(name=BetterIntelliJ, id=org.example.BetterIntelliJ
版权声明:本网站为非赢利性站点,本网站所有内容均来源于互联网相关站点自动搜索采集信息,相关链接已经注明来源。
联系我们