Concurrency vs Parrarel
Last updated
package main
import (
"fmt"
"time"
)
func text(num int, message string) {
for i := 0; i < num; i++ {
fmt.Printf("%s ", message)
}
}
func main() {
textSlice := []string{"test 1", "test 2", "test 3", "test 4", "test 5", "test 6", "test 7", "test 8", "test 9", "test 10"}
for _, val := range textSlice {
go text(5, val)
}
time.Sleep(3000*time.Millisecond)
fmt.Println("end")
}a 1 2 3 4 5 1 2 3 4 5 a b c d e 1 2 3 4 5 1 2 3 4 5 a b c d e a b c d e 1 2 3 4 5 a b c d e 1 2 3 4 5 a b c d e a b c d e a b c d e 1 2 3 4 5 1 2 3 4 5 a b c d e 1 2 3 4 5 b c d e a
b c d e a b c d e 1 2 3 4 5 1 2 3 4 5 end