Im looking for a good solution of coordinating several multithreading tasks.
Basically I have 2 tasks, I call A
and B
that need to be executed on a different thread than the main thread.
But B
must be started after A
has completed. A
and B
themselfes contain of several parts who should run parallel, called A1, A2, ... B1, B2, ...
.
And there is a caller from outside, who needs restart the whole job regardless of the progress. How can I archieve that? I thought of creating some sort of boolean array holding the information if each subtask (A1, ...) has already completed and if so start B. And check every few lines of code in each method if a cancellation has already been made. But it seems to me, that that is not an elegant solution and that there ways to coordinate excatly this.