# ParallelGateway - Process Instance remains after all sub-processes complete

**URL:** <https://forum.flowable.org/t/parallelgateway-process-instance-remains-after-all-sub-processes-complete/2821>\
**Category:** Flowable Engine\
**Created:** [October 29, 2018, 1:27pm UTC](https://forum.flowable.org/t/parallelgateway-process-instance-remains-after-all-sub-processes-complete/2821 "2018-10-29T13:27:58Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![adymlincoln](https://avatars.discourse-cdn.com/v4/letter/a/b5ac83/32.png) [@adymlincoln](https://forum.flowable.org/u/adymlincoln)\
**Post date:** [October 29, 2018, 6:24pm UTC](https://forum.flowable.org/t/parallelgateway-process-instance-remains-after-all-sub-processes-complete/2821/2 "2018-10-29T18:24:24Z")

</div>

Hi, I did some trial-n-error experiments using my simple parallel process XML. Also did some reading on various postings :

[https://community.alfresco.com/thread/219003-running-parallel-tasks-with-acitiviti](https://community.alfresco.com/thread/219003-running-parallel-tasks-with-acitiviti)  
[https://www.flowable.org/docs/userguide/index.html#bpmnConcurrencyAndTransactions](https://www.flowable.org/docs/userguide/index.html#bpmnConcurrencyAndTransactions)

I did manage to get this working so that the Process Instance gets completed, BUT the combinations of async and exclusive are IMPORTANT. Also, in order to work the Async Job Executor needs to be turned on…my was initial false (off) :

```
        ProcessEngineConfiguration ltheCfg = getProcessEngine().getProcessEngineConfiguration ();
        boolean ljobActivator = ltheCfg.getAsyncExecutor().isActive();
        if (!(ljobActivator)) {
            ltheCfg.getAsyncExecutor().start (); // Turns on the Async Job Executor...
        }
        ljobActivator = ltheCfg.getAsyncExecutor().isActive();

```

I fiddled with the following settings on the serviceTask XML elements and parallelGateway XML elements :

```
flowable:async="false" - On both serviceTask and parallelGateway
flowable:async="true" - On both serviceTask and parallelGateway
flowable:exclusive="false" - On serviceTask
flowable:exclusive="true" - On serviceTask

```

The final XML I settled on was :

```
<process id="simple-parallel">
    <startEvent id="theStart" />

    <sequenceFlow id="flow001" sourceRef="theStart" targetRef="theFork" />

    <parallelGateway id="theFork" flowable:async="true" />
    <sequenceFlow id="flow-002" sourceRef="theFork" targetRef="ParallelTaskA" />
    <sequenceFlow id="flow-003" sourceRef="theFork" targetRef="ParallelTaskB" />

    <userTask id="ParallelTaskA" name="Parallel Task A" />
    <sequenceFlow id="flow-004" sourceRef="ParallelTaskA" targetRef="parallel-task-a" />
        <!-- 
        <serviceTask id="parallel-task-a" flowable:delegateExpression="${beanParallelTaskA}" flowable:async="false" />
        <serviceTask id="parallel-task-a" flowable:delegateExpression="${beanParallelTaskA}" flowable:async="true" />
        -->
        <serviceTask id="parallel-task-a" flowable:delegateExpression="${beanParallelTaskA}" flowable:async="true" flowable:exclusive="false" />

    <sequenceFlow id="flow-004a" sourceRef="parallel-task-a" targetRef="theJoin" />

    <userTask id="ParallelTaskB" name="Parallel Task B" />
    <sequenceFlow id="flow-005" sourceRef="ParallelTaskB" targetRef="parallel-task-b" />
        <!-- 
        <serviceTask id="parallel-task-b" flowable:delegateExpression="${beanParallelTaskB}" flowable:async="false" />
        <serviceTask id="parallel-task-b" flowable:delegateExpression="${beanParallelTaskB}" flowable:async="true" />
        -->
        <serviceTask id="parallel-task-b" flowable:delegateExpression="${beanParallelTaskB}" flowable:async="true" flowable:exclusive="false" />

    <sequenceFlow id="flow-005a" sourceRef="parallel-task-b" targetRef="theJoin" />

    <parallelGateway id="theJoin" flowable:async="true" />
    <sequenceFlow sourceRef="theJoin" targetRef="theProcessEnd" />

    <endEvent id="theProcessEnd" />

</process>

```

hth,

adym

---

_[View the full topic](https://forum.flowable.org/t/parallelgateway-process-instance-remains-after-all-sub-processes-complete/2821)._
