gpt4 book ai didi

java - 像 GNU Make 一样并行化 ant?

转载 作者:太空宇宙 更新时间:2023-11-04 06:15:02 24 4
gpt4 key购买 nike

我需要执行多个ant任务。它们不必在同一个 JVM 中运行,类似 gnu make 的 fork() 执行这次是完美的 (*)。

但是,我需要的是带有 -j 标志的 gnu make 的功能:我需要能够限制并行运行的任务的最大数量。这是主要问题,在我当前的尝试(子任务)中,我没有找到任何选项。

那么,这个问题有解决办法吗?我真的不会用 exec 任务调用 gnu make...

(*) 是的,我知道它效率低下,请不要因此担心。一般情况下我也更喜欢多线程的方案,但是现在有特殊情况。

最佳答案

您可以使用<parallel> ant 中的任务,doc's描述如下:

Executes nested tasks in parallel with no guarantees of thread safety. Every task will run in its own thread, with the likelihood of concurrency problems scaling with the number of CPUs on the host system.

示例(来自他们的文档):

<parallel threadCount="4">
<dbpurge file="db/one" />
<dbpurge file="db/two" />
<dbpurge file="db/three" />
<dbpurge file="db/four" />
<dbpurge file="db/five" />
<dbpurge file="db/six" />
<dbpurge file="db/seven" />
<dbpurge file="db/eight" />
<!-- repeated about 40 times -->
</parallel>

关于java - 像 GNU Make 一样并行化 ant?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28196765/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com