go func() {
for i := 0; i < 100; i++ {
fmt.Println("协程1:" + strconv.Itoa(i))
}
}()
go func() {
for i := 100; i < 200; i++ {
fmt.Println("协程2:" + strconv.Itoa(i))
}
}()
time.Sleep(time.Second)time.Second)
![xiecheng.png](https://static.studygolang.com/181231/072d1f0827d3713694ebc6c233634cba.png)
更多评论
总有神奇的事,没在main函数里试,不过之前我发现test和main输出会不一样
=== RUN TestGo
协程1:0
协程1:1
协程1:2
协程1:3
协程1:4
协程1:5
协程1:6
协程1:7
协程1:8
协程1:9
协程1:10
协程1:11
协程1:12
协程1:13
协程1:14
协程1:15
协程1:16
协程1:17
协程1:18
协程1:19
协程1:20
协程1:21
协程1:22
协程1:23
协程1:24
协程1:25
协程1:26
协程1:27
协程1:28
协程1:29
协程1:30
协程1:31
协程1:32
协程1:33
协程1:34
协程1:35
协程1:36
协程1:37
协程1:38
协程1:39
协程1:40
协程1:41
协程1:42
协程1:43
协程1:44
协程1:45
协程1:46
协程1:47
协程1:48
协程1:49
协程1:50
协程1:51
协程1:52
协程1:53
协程1:54
协程1:55
协程1:56
协程1:57
协程1:58
协程1:59
协程1:60
协程1:61
协程1:62
协程1:63
协程1:64
协程1:65
协程1:66
协程1:67
协程1:68
协程1:69
协程1:70
协程1:71
协程1:72
协程1:73
协程1:74
协程1:75
协程1:76
协程1:77
协程1:78
协程1:79
协程1:80
协程1:81
协程1:82
协程1:83
协程1:84
协程1:85
协程1:86
协程1:87
协程1:88
协程1:89
协程1:90
协程1:91
协程1:92
协程1:93
协程1:94
协程1:95
协程1:96
协程1:97
协程1:98
协程1:99
协程2:100
协程2:101
协程2:102
协程2:103
协程2:104
协程2:105
协程2:106
协程2:107
协程2:108
协程2:109
协程2:110
协程2:111
协程2:112
协程2:113
协程2:114
协程2:115
协程2:116
协程2:117
协程2:118
协程2:119
协程2:120
协程2:121
协程2:122
协程2:123
协程2:124
协程2:125
协程2:126
协程2:127
协程2:128
协程2:129
协程2:130
协程2:131
协程2:132
协程2:133
协程2:134
协程2:135
协程2:136
协程2:137
协程2:138
协程2:139
协程2:140
协程2:141
协程2:142
协程2:143
协程2:144
协程2:145
协程2:146
协程2:147
协程2:148
协程2:149
协程2:150
协程2:151
协程2:152
协程2:153
协程2:154
协程2:155
协程2:156
协程2:157
协程2:158
协程2:159
协程2:160
协程2:161
协程2:162
协程2:163
协程2:164
协程2:165
协程2:166
协程2:167
协程2:168
协程2:169
协程2:170
协程2:171
协程2:172
协程2:173
协程2:174
协程2:175
协程2:176
协程2:177
协程2:178
协程2:179
协程2:180
协程2:181
协程2:182
协程2:183
协程2:184
协程2:185
协程2:186
协程2:187
协程2:188
协程2:189
协程2:190
协程2:191
协程2:192
协程2:193
协程2:194
协程2:195
协程2:196
协程2:197
协程2:198
协程2:199
--- PASS: TestGo (1.00s)
PASS
#3