Overlapping activations (multiple threads)

0 votes
asked May 6, 2017 in Closed question / help by purpletentacle (120 points)
I am trying to have overlapping activatins but they are always nested:

For instance:

@startuml

participant T1

participant T2

participant Main

T1 -> Main ++ #red: start

T2 -> Main ++ #yellow: start

Main --> T1 -- #red : done

Main --> T2 -- #yellow : done

@enduml

This will show nested red/yellow activations while I was expecting red to finish before yellow.

Is this supported? Am I doing something wrong?

Thanks!

2 Answers

0 votes
answered Jan 28, 2018 by Anthony-Gaudino (5,720 points)

If you activate a lifeline twice it will appear as nested, so you must deactivate it before reactivating.

@startuml
participant T1
participant T2
participant Main

T1 -> Main ++ #red: start
deactivate Main
T2 -> Main ++ #yellow: start

Main --> T1 -- #red : done
Main --> T2 -- #yellow : done
@enduml

I don't know exactly what you wanted to achieve.

0 votes
answered Mar 12, 2021 by KevinA
Maybe you wanted an existing Main to start something on existing Thread 1, and later start something on existing Thread 2 and get a return from T1 before getting one from T2.

This will show overlapping activations (on different lifelines.  Note that I moved Main to the 1st position):

@startuml
participant Main
participant T1
participant T2
Main -> T1 ++ #red: start
Main -> T2 ++ #yellow: start
T1 --> Main -- #red : done
T2 --> Main -- #yellow : done
@enduml
commented Mar 12, 2021 by KevinA
By the way, I am surprised and delighted that the "--" works the proper way.  I only discovered it by rearranging your attempt.  It is a miracle for me because that is exactly what I was looking for today (race condition between setups in 2 new threads).   I guess it wouldn't look so strange if I had written
"Main<--T1 -- #red : done".  with "T1" next to the "--".  In some diagrams, the arrow direction affects the layout; maybe not sequence diagrams.  (That makes things so much easier than activate and deactivate that I'm feeling a little giddy.)
...