3.4 Steps to Create a Concurrent Program

 < Day Day Up > 



3.4 Steps to Create a Concurrent Program

The procedure for creating programs used in this chapter has eight steps:

  1. Write a short description of the problem to be solved. This description should drive any choices of objects or functionality that must be made in subsequent steps.

  2. Create an ensemble by defining the objects and relationships that will be used in this program. A general rule is that nouns in the problem statement represent objects and/or attributes of the objects, and verbs represent actions and/or methods. However, do not simply choose objects based on the nouns and verbs in the description; instead, choose entities that will be useful in solving the problem stated in step 1.

  3. For each object, specify if that object should be active (executing actions and generating events) or passive (responding to events).

  4. Design the active objects using the verbs in the problem statement to define the flow of actions in the object. Specification of the active objects can be done using any procedural design technique, such as flow charts, pseudo-code, or activity diagrams. For the simple problems in this chapter, active objects are designed as pseudo-code.

  5. Design the passive objects using a state diagram. In the state diagram, the nodes are states that the object can be in and are represented by one or more instance variables in the object. Arcs are methods that can be executed when the object is in the correct state.

  6. Implement the active objects as Java threads.

  7. Implement the passive objects as monitors using the rules given in Section 3.7.

  8. Write a controlling object that will create instances of all the objects.

To demonstrate these steps, a simple program to solve the producer/ consumer problem is implemented in the next section, and each step is explained as it is applied to this problem.



 < Day Day Up > 



Creating Components. Object Oriented, Concurrent, and Distributed Computing in Java
The .NET Developers Guide to Directory Services Programming
ISBN: 849314992
EAN: 2147483647
Year: 2003
Pages: 162

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net