8

What is the difference between Join and Merge in Unified Modeling Language Activity Diagram. Give an example to understand more clearly.

AzeEm AnJum
  • 91
  • 1
  • 1
  • 4

2 Answers2

12

Join Node (see reference 1):

Join node is a control node that has multiple incoming edges and one outgoing edge and is used to synchronize incoming concurrent flows. Join nodes are introduced to support parallelism in activities.

Merge Node (see reference 2):

Merge node is a control node that brings together multiple incoming alternate flows to accept single outgoing flow. There is no joining of tokens. Merge should not be used to synchronize concurrent flows.


For example in below diagram:

A decision is used after a fork, the two flows coming out of the decision need to be merged into one before going to a join.

Why?: Otherwise, the join will wait for both flows.

So, Activity 2 and Activity 3 are our alternate flows and only one of which will arrive. And they are not synchronize incoming.

However, the Concurrent_Activity and result of decision between Activity 1 and Activity 2 (that merged into one output) are synchronize incoming concurrent flows. The join waits for both to perform and continue.

enter image description here

Gholamali-Irani
  • 3,851
  • 5
  • 24
  • 55
  • 1
    Even if all examples of the specification are like @Gholamali-Irani explains, you can use merge node after a fork, it is not used to merge alternate flows only. The specification explains "A MergeNode is a control node that brings together multiple flows without synchronization. " – granier Jan 07 '18 at 13:41
  • Can a merge has more than 3 input flows? – Nuwan Karunarathna Sep 12 '18 at 13:39
  • TL;DR and more simple version: JOIN requires both activities that are coming in to be completed. MERGE just waits for one of the incoming activities to be completed. JOIN blocks, MERGE does not. – Michael Ziluck Dec 11 '18 at 14:59
3

To elaborate on @Gholamali-Irani's answer: Activity diagrams are derived from Petri nets. In short you have to imagine a single "token" that starts at the one initial start point (that fat dot). The token travels along a path until it vanishes in one of those (circled dot) final terminals (or as UML allows in actions which have no outgoing path). The fork nodes will multiply that single token into as many tokens as it has outgoing paths (UML also has an implicit fork for actions with multiple outgoing paths which are not guarded). So these multiple tokens travel independently until they either vanish like described above or they reach a join (or action) with multiple ingoing paths. Here the token waits until all paths are fed with a single token. These multiple tokens are then merged into a single one which travels on as usual.

With this ruleset you can model any complex concurrent network.

qwerty_so
  • 31,206
  • 7
  • 53
  • 81
  • Thanks a lot for **Patri net** hint. It is mathematical modeling languages. I can use it to map my Activity Diagrams to mathematical world in my research papers. – Gholamali-Irani Jan 07 '18 at 12:41