diff --git a/concurrency b/concurrency index eabb86a..7ee21cc 100755 Binary files a/concurrency and b/concurrency differ diff --git a/concurrency.go b/concurrency.go index ad3f75f..53e9e44 100644 --- a/concurrency.go +++ b/concurrency.go @@ -9,15 +9,28 @@ import ( ) func ta(tamsec int) { + n := 0; for i := 0; i < 9999999; i++ { - fmt.Println("Thread A: counter: ", i) + n++; + if n == 23 { + n = 0; + fmt.Println("\n\nThread A Thread B "); + fmt.Println("-------------- ---------------"); + } + fmt.Println("A Counter: ", i) time.Sleep(time.Duration(tamsec) * time.Millisecond) } } func tb(tbmsec int) { - + n := 0; for i := 0; i < 9999999; i++ { - fmt.Println(" Thread B counter: ", i) + n++; + if n == 19 { + n = 0; + fmt.Println("\n\nThread A Thread B "); + fmt.Println("-------------- ---------------"); + } + fmt.Println(" B Counter: ", i) time.Sleep(time.Duration(tbmsec) * time.Millisecond) } } @@ -28,6 +41,8 @@ func timeoutfunc(t chan bool, toutsec int) { func main() { + fmt.Println("Thread A Thread B "); + fmt.Println("-------------- ---------------"); var tamsec int = 300 var tbmsec int = 100 var toutsec int = 15