码迷,mamicode.com
首页 > 其他好文 > 详细

goroutines _ golang

时间:2015-03-15 15:13:38      阅读:144      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!