首页 > 其他 > 详细

goroutines _ golang

时间:2015-03-15 15:12:12      阅读:234      评论:0      收藏:0      [点我收藏+]

A goroutine is a loghtweight thread of execution

package main

import (
    "fmt"
)

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

func main() {

    f("direct")

    go f("goroutine")

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

    var input string

    fmt.Scanln(&input)
    fmt.Println("done")
}
direct ; 0
direct ; 1
direct ; 2
goroutine ; 0
goroutine ; 1
goroutine ; 2
going
xxjkx
done

总结 :

  1 : ....

goroutines _ golang

原文:http://www.cnblogs.com/jackkiexu/p/4339755.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!