【问题标题】:What is the difference between Future and future?未来和未来有什么区别?
【发布时间】:2017-03-30 12:27:22
【问题描述】:

我是 scala 的新手。在 Future 中,我看到它以两种不同的方式使用,即 Future 和 Future。

例子:

val sayHello = Future {
    Thread.sleep(1000)
    "hello"
  }

同样,

val sayHello = future {
    Thread.sleep(1000)
    "hello"
  }

但我没有发现输出有任何区别。如果有人我会很高兴

让我明白。

【问题讨论】:

  • 有一个 def futurescala.concurrent 包对象的一部分。

标签: scala future


【解决方案1】:

确实是一回事,而从 2.11.0 开始,future(小写)实际上已被弃用。

查看scala lang中的实际代码:https://github.com/scala/scala/blob/v2.12.0/src/library/scala/concurrent/package.scala#L101

【讨论】:

    猜你喜欢
    • 2016-08-16
    • 2015-12-27
    • 2011-03-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多