How do I represent a thread in UML?

John Moore

In class diagrams you could elect to show that a class extends class Thread (using a generalization relationship) or that it implements interface Runnable (using either the “lollipop” notation or a realization relationship), but UML has the concept of an active class just for this purpose. Graphically, the rectangle for an active class uses thick lines for its border, and it can be annotated with one of two predefined UML stereotypes for active classes – process and thread. For Java threads, I would use the active class notation with the thread stereotype.

Other UML features which can be useful for representing thread-related information include:

  • Operations (i.e., method declarations) can be stereotyped as concurrent, which is equivalent to Java's synchronized property.
  • State diagrams in UML support the concept of concurrent substates.
  • Interaction diagrams (the UML name which encompasses both sequence diagrams and collaboration diagrams) allow the specification of asynchronous messages.
  • Activity diagrams use a synchronization bar to specify forking and joining of concurrent activities.

Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact