From 7052c12ae192b902a35d692a422ee85bef5a3712 Mon Sep 17 00:00:00 2001 From: oabrivard Date: Sun, 20 Aug 2023 00:14:23 +0200 Subject: [PATCH] Initial commit --- .gitignore | 2 ++ chapter13/concurrency.go | 30 ++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 chapter13/concurrency.go 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()") +}