# Using ParallelizableTask

**URL:** <https://discuss.gradle.org/t/using-parallelizabletask/14634>\
**Category:** Help/Discuss\
**Created:** [February 19, 2016, 9:49pm UTC](https://discuss.gradle.org/t/using-parallelizabletask/14634 "2016-02-19T21:49:57Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![awrichar](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/awrichar/32/7078_2.png) [@awrichar](https://discuss.gradle.org/u/awrichar)\
**Post date:** [February 19, 2016, 9:49pm UTC](https://discuss.gradle.org/t/using-parallelizabletask/14634/1 "2016-02-19T21:49:57Z")

</div>

The docs indicate that I can mark specific tasks as parallelizable using the `@ParallelizableTask` annotation. As far as I can tell, this annotation doesn’t do anything. Am I missing a piece here, or misunderstanding the purpose of this annotation?

Example build.gradle below - my “taska” and “taskb” scripts are simple bash scripts that do `echo "start"; sleep 5; echo "end"`. With the code below, I see that the tasks are executed separately in series. Can I get them to execute in parallel?

```
@ParallelizableTask
class ParallelTask extends Exec {}

task taska(type: ParallelTask) {
    commandLine './taska'
}

task taskb(type: ParallelTask) {
    commandLine './taskb'
}
```

---

<div class="post-metadata">

**Author:** ![sterling](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/sterling/32/5395_2.png) [@sterling](https://discuss.gradle.org/u/sterling)\
**Post date:** [February 20, 2016, 4:03am UTC](https://discuss.gradle.org/t/using-parallelizabletask/14634/2 "2016-02-20T04:03:54Z")

</div>

By default, it doesn’t do anything. It’s a hint for the task executor to schedule the task to run in parallel.

There’s not a public way to turn this check on (i.e., a command-line flag), but we do have a hidden system property to enable more aggressive parallel execution: [https://github.com/gradle/gradle/blob/master/subprojects/core/src/main/groovy/org/gradle/execution/taskgraph/DefaultTaskExecutionPlan.java#L59](https://github.com/gradle/gradle/blob/master/subprojects/core/src/main/groovy/org/gradle/execution/taskgraph/DefaultTaskExecutionPlan.java#L59)

We have test coverage for using this, but it’s possible to write unsafe tasks that we can’t detect as non-parallel safe, so we haven’t taken the time to make this public. Anecdotally, I use this for the gradle build all the time and haven’t noticed any problems. I think eventually this is going to get rolled into `--parallel` and/or be enabled by default.

---

<div class="post-metadata">

**Author:** ![awrichar](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/awrichar/32/7078_2.png) [@awrichar](https://discuss.gradle.org/u/awrichar)\
**Post date:** [February 20, 2016, 12:53pm UTC](https://discuss.gradle.org/t/using-parallelizabletask/14634/3 "2016-02-20T12:53:11Z")

</div>

Thanks for the tip. I tried this:

```
gradle -Dorg.gradle.parallel.intra=true taska taskb

```

but it still doesn’t seem to make a difference. I also tried creating a 3rd task that just depends on the other two and executing that (in case dependencies are parsed differently from tasks directly on the command line), but still no luck. I’m using Gradle 2.11 by the way.

I can dive into the source a little more and see what I can figure out, but let me know if you can think of anything else I’m missing. Thanks!

---

<div class="post-metadata">

**Author:** ![sterling](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/sterling/32/5395_2.png) [@sterling](https://discuss.gradle.org/u/sterling)\
**Post date:** [February 20, 2016, 3:45pm UTC](https://discuss.gradle.org/t/using-parallelizabletask/14634/4 "2016-02-20T15:45:52Z")

</div>

Ah, sorry. You have to enable `--parallel` too. I forgot I had `org.gradle.parallel=true` in my `~/.gradle/gradle.properties`.

---

<div class="post-metadata">

**Author:** ![awrichar](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/awrichar/32/7078_2.png) [@awrichar](https://discuss.gradle.org/u/awrichar)\
**Post date:** [February 20, 2016, 4:38pm UTC](https://discuss.gradle.org/t/using-parallelizabletask/14634/5 "2016-02-20T16:38:35Z")

</div>

Yea, I think I have it in my gradle.properties as well - would need to double check that machine to be sure, but I usually have that set.

---

<div class="post-metadata">

**Author:** ![awrichar](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/awrichar/32/7078_2.png) [@awrichar](https://discuss.gradle.org/u/awrichar)\
**Post date:** [February 25, 2016, 3:32pm UTC](https://discuss.gradle.org/t/using-parallelizabletask/14634/6 "2016-02-25T15:32:07Z")

</div>

Just got to check up on this again - and it turns out I didn’t have `org.gradle.parallel` set on this particular machine. Passing `--parallel` made things work. Thanks for the help!
