Java Program Using Threads
Hi there, im really new and have just started programming in Java, i have to create a java program which implement threads. Thread.Wait, thread.start them etc.
Here is the problem, any guidance would be great cheers guys
The manager of a company employs 3 secretaries who are of varying ability, but who all work extremely fast. Secretary A is the most experienced secretary and is capable of typing up a letter once every second. Secretary B is less experienced and is capable of typing up a letter once every 2 seconds. Secretary C is the junior secretary and is capable of typing up a letter once every 4 seconds. When a secretary has typed up a letter he leaves it in the manager抯 tray for him to remove and sign. The manager removes and signs a letter from the tray once every 2 seconds. The tray can hold a maximum of 5 letters at a time. The tray抯 limited capacity sometimes causes the various workers to be delayed. For example, if the tray is full after a letter has been typed, the secretaries must wait until the manager makes a space available before they can add another letter to the tray. Similarly, the manager must wait for at least one letter to appear in the tray before he can take it out and sign it.
In your program, make use of threads to represent each of the workers (the 3 secretaries and the manager), so that they can work in parallel. You will also need to declare a tray object, and ensure that all communication is properly synchronised to avoid indeterminacy and deadlock. While an office worker is busy typing a letter or signing it, you should send that thread to sleep for the appropriate time period. This can be achieved with a call to:
Thread.sleep(m);
where m is the number of milliseconds for which the thread should suspend.
The output from your program should take the form of a running commentary on the activity taking place in the office. An extract from it might look something like this (though it is up to you how you word this):
?.
Secretary A is ready to type a letter
Secretary A has typed a letter, number now typed = 6
Tray full. Secretary must wait until a letter has been removed before adding another
Secretary C has typed a letter, number now typed = 2
Tray full. Secretary must wait until a letter has been removed before adding another
A letter has been removed from the tray. Tray = 4
The Manager has taken a letter from the tray to sign, number signed = 4
The Manager is ready to sign a letter
etc
?.
Run your simulation until the secretaries have typed and filed 7 letters each, and the manager has removed and signed all 21 letters.
Thanks again

