diff --git a/.gitignore b/.gitignore index adf8f72..e620e5a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +.DS_Store + # ---> Go # If you prefer the allow list template instead of the deny list, see community template: # https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore diff --git a/chapter13/concurrency.go b/chapter13/concurrency.go new file mode 100644 index 0000000..7a7cc06 --- /dev/null +++ b/chapter13/concurrency.go @@ -0,0 +1,30 @@ +package main + +import ( + "fmt" +) + +func a(c chan bool) { + for i := 0; i < 50; i++ { + fmt.Print("a") + } + + c <- true +} + +func b(c chan bool) { + for i := 0; i < 50; i++ { + fmt.Print("b") + } + + c <- true +} + +func main() { + c := make(chan bool) + go a(c) + go b(c) + <- c + <- c + fmt.Println("end main()") +}