what is the overall context of your question? In general, it is often not the best idea to store variables locally. Also, dealing with executionIds can be tricky since they can change over time.
Quote from the docs:
In addition, it is not guaranteed that the same execution that started a given activity instance will also end it. The process engine performs several internal optimizations concerning the compacting of the execution tree which might lead to executions being reordered and pruned. This can lead to situations where a given execution starts an activity instance but another execution ends it. Process Engine Concepts | docs.camunda.org
Maybe you can explain what you aim to do with a simple BPMN model.
I do not have the ability to copy a process to a forum, development on another PC. The process represents 4 user tasks with 3 gateways, tasks are allocated to a subprocess, the subprocess is launched by the transfer of the collection of identifiers , respectively, a poodem occurs by extracting these variables (in order to be sure that the completed task is the right task), and it seems to work but I wanted a more beautiful solution
But now, after your answer (many thanks for him), I wondered if I did it at all ,
The first experience with BPM