Section 3.4. Doing Multiple Tasks at the Same Time


3.4. Doing Multiple Tasks at the Same Time

Consider a computer assembly workflow that involves the following steps:

  1. Prepare the case.

  2. Prepare the motherboard.

  3. Install the motherboard.

  4. Install the drives.

  5. Install the video card, sound card, and modem.

So far we've covered enough activity diagram notation to model this workflow sequentially. But suppose the entire workflow can by sped up by preparing the case and the motherboard at the same time since these actions don't depend on each other. Steps that occur at the same time are said to occur concurrently or in parallel.

Figure 3-8. In UML 2.0, it's better to be as clear as possible and to show merge nodes


You represent parallel actions in activity diagrams by using forks and joins, as shown in the activity diagram fragment in Figure 3-9.

Figure 3-9. Both outgoing paths are followed at the fork, in contrast with decision nodes, where only one outgoing path is taken


After a fork in Figure 3-9, the flow is broken up into two or more simultaneous flows, and the actions along all forked flows execute. In Figure 3-9, Prepare Case and Prepare Motherboard begin executing at the same time.

The join means that all incoming actions must finish before the flow can proceed past the join. Forks and joins look identicalthey are both drawn with thick barsbut you can tell the difference because forks have multiple outgoing flows, whereas joins have multiple incoming flows.

In a detailed design model, you can use forks to represent multiple processes or multiple threads in a program.


Figure 3-10 completes the activity diagram for the computer assembly workflow.

Figure 3-10. The computer assembly workflow demonstrates how forks and joins work in a complete activity diagram


When actions occur in parallel, it doesn't necessarily mean they will finish at the same time. In fact, one task will most likely finish before the other. However, the join prevents the flow from continuing past the join until all incoming flows are complete. For example, in Figure 3-10 the action immediately after the joinInstall Motherboardexecutes only after both the Prepare Case and Prepare Motherboard actions finish.




Learning UML 2.0
Learning UML 2.0
ISBN: 0596009828
EAN: 2147483647
Year: 2007
Pages: 175

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