在C#中你可以写:
var alphaTask = Task.Factory.StartNew<alpha>(() =>
{
return someWork(n);<br>
});
// ... do some other work, and later get the result from the task<br>
var res = alphaTask.Result;
Run Code Online (Sandbox Code Playgroud)
这个简单的结构在Scala中会是什么样子?
谢谢.
Dav*_*ith 10
在Scala 2.8中,最简单的等价物是
val future = Futures.future{
someWork(n)
}
// ... do some other work, and later get the result from the task
val res = future();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
200 次 |
| 最近记录: |