Question: 4 (20 points) Write a complete Go program whose sain function spawn they alternate only two gorou- tines. Synchronize those two goroutines, without busy waiting,
4 (20 points) Write a complete Go program whose sain function spawn they alternate only two gorou- tines. Synchronize those two goroutines, without busy waiting, s0 execution to cooperatively print ping pong to stderr 100 times. s ./PingPong 1 ping // printed by goroutine1 2 pong // printed by goroutine 2 3 ping // printed by goroutine 1 4 pong // printed by goroutine 2 5 ping // printed by goroutine1 6 pong // printed by goroutine 2 7 ping /1 printed by goroutise 8 pong // printed by goroutine 2 9 ping // printed by goroutine 10 pong 1/ printed by goroutine 2 99 ping // printed by goroutine 1 100 pong // printed by goroutine 2 Odd lines numbers must be printed by the first goroutine and even line numbers must be printed by the second goroutine. Your program must not contain any race conditions. Do not give more than 25 lines of code
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
