Concurrency design problem (paper-only). Threading is not available in the sandbox; the auto-grader validates a single-threaded equivalent.
You have a class FizzBuzz shared by four threads. Each thread is responsible for one role:
- Thread 1: prints
"fizz"for numbers divisible by 3 but not 5. - Thread 2: prints
"buzz"for numbers divisible by 5 but not 3. - Thread 3: prints
"fizzbuzz"for numbers divisible by both 3 and 5. - Thread 4: prints the number itself for numbers not divisible by 3 or 5.
For a positive integer n, the threads collectively output the FizzBuzz sequence from 1 to n, separated by spaces.
For the auto-grader: implement fizzBuzzSeq(n) returning the joined sequence. Your implementation should make explicit the role-dispatch each thread would perform - in the explanation we describe the four-thread design with a shared counter and per-role wake conditions.