« Return to Thread: future hangs

RE: future hangs

by Detering Dirk-2 :: Rate this Message:

Reply to Author | View in Thread

Nice subject ...

> This simple application hangs at "println(s())". Apparently,
> the mistake is so simple that I cannot find it... what am I
> doing wrong? Defining getData and printing s() in the
> interactive scala shell works just fine. Thanks!
>
> object Test extends Application {
>
>     val s = future(getData("AAPL\n"))
>     val t = getData("INTC\n")
>     println(t) // that's fine
>     println(s()) // hangs here

Well, the println(s()) will first wait for the result of s,
but -due to the definition of s- that doesn't come now, but
in future.

Due to the functional aspect, this is true for every point in time.

(I would recommend renaming the val s into val godot,
and then putting the println(godot()) into a method called
"mañana"...).


Ðet


PS: No, I'm NOT stressed, Mum!!!!

 « Return to Thread: future hangs