...

/

Printing Number Series (Zero, Even, Odd)

Printing Number Series (Zero, Even, Odd)

This problem is about repeatedly executing threads which print a specific type of number. Another variation of this problem; print even and odd numbers; utilizes two threads instead of three.

We'll cover the following...

Problem

Suppose we are given a number n based on which a program creates the series 010203...0n. There are three threads t1, t2 and t3 which print a specific type of number from the series. t1 only prints zeros, t2 prints odd numbers and t3 prints even numbers from the series. The code for the class is given as follows:

class PrintNumberSeries   
    #constructor
    def initialize(n) 
        @n = n    
    end
    
    def PrintZero
    end

    def PrintOdd
    end

    def PrintEven
    end

end

You are required to write a program which takes a user input n and outputs the number series using three threads. The three threads work together to print zero, even and odd numbers. The ...