普通网友 2017-10-27 17:17
浏览 50
已采纳

从调用另一个goroutine的goroutine返回

I wonder what happens to goroutines called from another goroutine when it returns. Do they continue running or get terminated? Here is a sample code to show what I mean:

func func() {
    // Doing something
}

func func2() {
        go func()
        // Doing things that end with a return
    }

func main() {
    go func2()
}

what happens to func() goroutine when func2() goroutine returns?

  • 写回答

1条回答 默认 最新

  • dongzhi7641 2017-10-27 18:03
    关注

    You can make an experiment on excellent https://play.golang.org playground! I recommend experiment there - it helps very much with golang studying.

    https://play.golang.org/p/OJ9sgakV-S

    I've added 2 second delay, because if program exit too quickly, you 'll not see results from goroutines.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 TLS1.2协议通信解密
  • ¥40 图书信息管理系统程序编写
  • ¥20 Qcustomplot缩小曲线形状问题
  • ¥15 企业资源规划ERP沙盘模拟
  • ¥15 树莓派控制机械臂传输命令报错,显示摄像头不存在
  • ¥15 前端echarts坐标轴问题
  • ¥15 ad5933的I2C
  • ¥15 请问RTX4060的笔记本电脑可以训练yolov5模型吗?
  • ¥15 数学建模求思路及代码
  • ¥50 silvaco GaN HEMT有栅极场板的击穿电压仿真问题