Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package futures
- import scala.concurrent._
- import duration._
- import ExecutionContext.Implicits.global
- import scala.language.postfixOps
- object FutureTestMain {
- def wasteTime(n: Int): Int =
- (1 to n).foldLeft(1) { (x,y) =>
- x + y + Math.sqrt(x * y).toInt
- }
- def main(args: Array[String]) = {
- val n = 10000000
- println("Starting")
- val fut: Future[Int] = Future {
- wasteTime(n)
- }
- val x = wasteTime(n * 2)
- println("Inter Result: " + x)
- val result = Await.result(fut, 10 seconds)
- println("Future Result: " + result)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement