Hi guys revising for an exam and im fine with the theory stuff but heres one question:
A large ornamental garden is open to the members of the public who can enter through two gates: east gate or the west gate. The management wants to determine how many people there are in the garden at any time. Write a program to implement the population count that contains two concurrent threads (each controlling a single gate). The gardens is open 1 hour a day. You can assume during this time no one was allowed to leave. 18marks
This is a closed book exam! So for this I would write two threads east and west. Start them in the main method. Incrementing a counter instance variable, within the run methods of the thread class.
Please correct anything you guys think above. How would you guys prevent the threads interfereing with each other? and how does the 1 hour get into it?