Fizz Buzz Problem
This problem explores a multi-threaded solution to the very common Fizz Buzz programming task
We'll cover the following
Problem Statement
FizzBuzz is a common interview problem in which a program prints a number series from 1 to n such that for every number that is a multiple of 3 it prints “fizz”, for every number that is a multiple of 5 it prints “buzz” and for every number that is a multiple of both 3 and 5 it prints “fizzbuzz”. We will be creating a multi-threaded solution for this problem. Suppose we have four threads t1, t2, t3 and t4. Thread t1 checks if the number is divisible by 3 and prints fizz. Thread t2 checks if the number is divisible by 5 and prints buzz. Thread t3 checks if the number is divisible by both 3 and 5 and prints fizzbuzz. Thread t4 prints numbers that are not divisible by 3 or 5. The workflow of the program is shown below:
Level up your interview prep. Join Educative to access 80+ hands-on prep courses.