1. Multithreading Synchronization I was given two functions, func_a() and func_b(), each running in a separate thread: void printA() { while(1) print("a"); } void printB() { while(1) print("b"); } Each function runs indefinitely, printing either "a" or "b". The task was to introduce synchronization mechanisms (such as mutexes, semaphores, or condition variables) to ensure the output alternates as ABABABAB rather than random sequences like AAA BBB or AAABBAAAAA. This problem is similar to LeetCode 1115 - Print Foo Bar Alternately, where two threads need to synchronize their execution.
Check out your Company Bowl for anonymous work chats.