3.4. Doing Multiple Tasks at the Same TimeConsider a computer assembly workflow that involves the following steps:
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 nodesYou 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 takenAfter 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.
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 diagramWhen 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. |