Can Ant launch two java applications concurrently?

会有一股神秘感。 提交于 2019-11-27 15:48:33
Mark O'Connor

You can spawn two java programs from within an Ant parallel task.

<parallel>
  <sequential>
    <java fork="true" classname="prog1 .... >
  </sequential>
  <sequential>
    <sleep seconds="30"/>
    <java fork="true" classname="prog2.... >
  </sequential>
</parallel>

The sleep task in the second thread could be replace by a waitfor condition.

You can certainly spawn processes from Ant. Here's a simple example:

<target name="sleeper">
    <exec executable="sleep" spawn="yes">
       <arg value="100" />
    </exec>
</target>

If you run this task* you'll see Ant run to completion, but a ps will show the sleep persists.

The java task also supports spawn.

**the example assumes a UNIX variant OS as it uses the sleep command*.

Arkaaito

Look at the doc for Ant's <exec> directive - you should be able to add a call to the target application with <exec> that will amp off by using the "spawn" parameter.

Edit: sorry, "amp off" is slang for running a process in the background, which allows Ant to continue working while that process runs.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!