title: How to design an execution engine for a sequence of tasks
body: <p>I am trying to code a problem in Java where I have to execute a bunch of tasks. </p>
  
  <p><strong>Problem</strong></p>
  
  <p>Execute a job which consists of multiple tasks and those tasks have dependencies among them.</p>
  
  <p>A job will have a list of tasks and each such task will further have a list of successor tasks (Each successor task will have its own successor tasks - you can see the recursive nature here). Each successor task can start its execution if - </p>
  
  <ol>
  <li><p>It is configured to be executed on partial execution of its predecessor task. In this case, predecessor task will notify that it has completed partially and my successor tasks can start</p></li>
  <li><p>Successful completion of its predecessor task.</p></li>
  </ol>
  
  <p><strong>Example</strong></p>
  
  <p>Job having 2 initial tasks A and B. A has 2 successor tasks M and N. B has 1 successor task P. P has 2 successor tasks Y and Z. </p>
  
  <p>M can start on partial completion of its predecessor task A. 
  Z can start on partial completion of its predecessor task P.
  N, P and Y can start only on completion of their predecessor tasks A, B and P respectively.</p>
  
  <p><img src="https://i.stack.imgur.com/WQkS9.png" alt="Tasks Hierarchy (A and B can start in parallel)"></p>
  
  <p>I have to design the execution of such a workflow/job. In the design we have to acknowledge the partial completion event sent by a predecessor task so that its successor task can be started. How should I go about it? Is there any design pattern which suits this problem in concurrency?</p>