-
Notifications
You must be signed in to change notification settings - Fork 0
/
multi.go
52 lines (42 loc) · 865 Bytes
/
multi.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package main
import (
"fmt"
"time"
)
func testingMore(ender chan string) {
fmt.Println("Func3")
time.Sleep(1*time.Second)
fmt.Println("Func3 Done")
ender <- "Bye World"
}
func testingStuff(ender chan string) {
fmt.Println("Secondary func")
time.Sleep(3*time.Second)
fmt.Println("Secondary Done")
ender <- "Hello World"
}
func main() {
ch := make(chan string)
fmt.Println("Main func")
//go testingStuff(ch)
//go testingStuff(ch)
//go testingStuff(ch)
//go testingMore(ch)
for i := 0; i < 4; i++ {
go testingStuff(ch)
go testingMore(ch)
}
for i := 0; i < 4; i++ {
test := <- ch
fmt.Println(test)
}
//test1 := <- ch
//test2 := <- ch
//test3 := <- ch
//test4 := <- ch
//fmt.Println("Test1:", test1)
//fmt.Println("Test2:", test2)
//fmt.Println("Test3:", test3)
//fmt.Println("Test4:", test4)
fmt.Println("Primary Done")
}