|
I am writing a program for my operating systems class, and I need help. I have a general idea of what to do, but I am getting all kinds of errors, which makes me think I should just start over.
The purpose of this exercise is to simulate a candy factory. Three ingredients are needed to make a candy bar: chocolate, nuts and a wrapper. Assuming that there are three candy bar making machines (clients), the first client has an unlimited supply of chocolate, the second client has an unlimited supply of nuts, and the third client has an unlimited supply of wrappers. Each client takes a random amount of time to make a candy bar as soon as it has all three ingredients.
Theres a fourth machine (agent), with an unlimited supply of all three ingredients. The agent places two ingredients on the table at the same time. From the table these two ingredients are immediately available for the agents to use to make a candy bar. The agent decides at random which two of the ingredients it will put on the table. As soon as a client can use the ingredients placed on the table, it takes them (both at the same time). At that point the agent is immediately free (without waiting for the client to finish making a candy bar) to put down two new ingredients.
So I have to write a java program that uses threads to simulate the activities of the agent and the clients. And as much as possible, the agent's activities have to be independent from the clients, and the clients' activities should be independent from each other.
Is anyone a threading guru/wants to help me?
_________________ Joie
|