我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

够程另一个函数内运行

It may be a silly question, but I just wonder,

code:

func sumNumber(value int){
    array1 := []int{3, 6, 7)

    for _, v:= range array1{
        go anotherFunction(v) // goroutine function is run three times 
    }
}

My question is, Which one will finish first, func sumNumber or goroutine anotherFunction?

This completely depends on so many factors,especially on what "anotherFunction" does. However the sumNumber function definitely is going to be very short lived as it is just going to initiate three go routines and exit.

近期文章

  • 文字被表格挡住无法正常显示
  • 为什么不能在Go的for循环中使用'var'? [关闭]
  • time.Parse错误,我在做什么错?
  • 无法通过struct方法替换指针
  • 究竟math.Exp有什么作用?
  • 如何在os.Args中保留引号
  • 在Go中打印频道内容
  • 将结构B(从结构A继承)附加到结构A的切片上
  • GO:我正在尝试猜测我的号码,但是我的程序无法正确解释数字
  • 如何在golang中为外部打印变量?
  • 如何使用Go编程语言对文件名进行排序?
  • 在go中遍历字符串字符的最正确方法是什么
  • 在Go中使用HTTP与使用TCP套接字将文件下载/上传到服务器有什么优势? [关闭]
  • 嵌入式结构反对情况
  • 在golang中发送像请求一样的curl
  • 开关或操作员编译器错误
  • 将数据转换为base64编码
  • 在Go中递增指针[重复]
  • Go无法从字符串创建全局字节片
  • 无法解析go中的json文件[重复]

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华