有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java如何在Scala中强制指令的执行顺序

我注意到,Scala并不总是按顺序执行指令。例如,如果您有以下说明

var a = command1.!
var b = command2.!

第二条指令可以在第一条指令之前执行,因为它对该指令没有任何依赖关系。所以,我的问题是,如何强制在第一条指令之后执行第二条指令


共 (1) 个答案

  1. # 1 楼答案

    回答以下问题:如何编写ProcessBuilder?,医生说:

    Two existing ProcessBuilder can be combined in the following ways:

    They can be executed in parallel, with the output of the first being fed as input to the second, like Unix pipes. This is achieved with the #| method.

    They can be executed in sequence, with the second starting as soon as the first ends. This is done by the ### method.

    The execution of the second one can be conditioned by the return code (exit status) of the first, either only when it's zero, or only when it's not zero. The methods #&& and #|| accomplish these tasks.