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

标签 java scala apache-spark

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

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

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

最佳答案

回答问题“我如何编写 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.

关于java - 如何强制 Scala 中指令的执行顺序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30829572/

相关文章:

java - 错误: undefined reference to 'libiconv_close' in Ndk Android Studio

scala - Scala 中两个集合的并集

scala - 如何将已知的结构化 RDD 转换为 Vector

java - 如何在从 Spark 使用 Kafka 时获取偏移量 ID,将其保存在 Cassandra 中并使用它来重启 Kafka?

performance - 我在哪里可以找到 Spark 中的操作成本?

Java LongStream求和int数组元素

java - 为什么创建从Internet下载gradle.zip的Gradle项目?

java - 如何以编程方式在锁定屏幕上设置快捷方式

Scala 'fromFile' 怪异?

scala - 如何在 Spark 中编写干净的调试语句?