Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/scala/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Scala中的异步编码_Scala_Web Crawler - Fatal编程技术网

Scala中的异步编码

Scala中的异步编码,scala,web-crawler,Scala,Web Crawler,可能重复: Scala中是否有与F#异步工作流等效的工作流?我想用这个同时抓取网页 谢谢要并行异步执行任务,只需使用Actor.Actor方法: import scala.actors.Actor._ actor { // code here is excuted asynchronously } 要执行任务并等待结果,请使用futures: import scala.actors.Futures.future val f = future { // code here is

可能重复:

Scala中是否有与F#异步工作流等效的工作流?我想用这个同时抓取网页


谢谢

要并行异步执行任务,只需使用
Actor.Actor
方法:

import scala.actors.Actor._

actor {
  // code here is excuted asynchronously  
}
要执行任务并等待结果,请使用futures:

import scala.actors.Futures.future

val f = future {
  // code here is excuted asynchronously
  // last expression is returned
}
//... other code
val result = f() // block until f is completed and return the value
要了解更复杂的工作流,请查看Scala(或Akka)参与者。您还可以看看JavaNIO,它允许异步IO操作