Please tell me where i am wrong in this program and how can i do it in a better wayBookmark:Question:
Create three Classes: Storage, Counter and Printer. The Storage class should store an integer. The Counter class should create a
thread that starts from counting from 0(0, 1, 2, 3....) and stores each value in the Storage class. The Printer class should create a thread that keeps reading the value in the Storage class and printing it.
Create a program that create an instance of the Storage class, and sets up a Counter and a Printer object to operate on it. Modify the program to ensure that each number is printed exactly once, by adding suitable synchrnization