```go
package main
import(
"fmt"
"time"
)
//class Thread
type Thread struct{
name string
}
func (this *Thread)run()string{
fmt.Println(this.name, "start")
return ""
}
//class Threads
type Threads struct{
t map[string]Thread
}
func (this *Threads)runn()string{
for key, v:=range this.t{
fmt.Println("Key:",key, "Value:", v.name)
go v.run() //这个地方输出的不是我预期的, why
}
return ""
}
func main(){
fmt.Println("main start")
var tt Threads = Threads{}
tt.t = make(map[string]Thread)
tt.t["one"] = Thread{name:"one1"}
tt.t["two"] = Thread{name:"two2"}
tt.t["three"] = Thread{name:"three3"}
tt.runn() //why
time.Sleep(5*1e9)
fmt.Println("main end")
}
```
```
type Threads struct{
t map[string]*Thread
}
```
这种方式可以的,但是为什么,我不知道,麻烦帮忙解释一下吗@channel
#6
更多评论
```
type Threads struct{
t map[string]Thread
}
```
改为
```
type Threads struct{
t map[string]*Thread
}
```
#2