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?

Thanks guys

Yeah i guess i was thinking it would be something more complex than that but you're right. What about the 1 hour stipulation?

This question has already been answered. Start a new discussion instead.