/ Published in: Scala
A Simple and Complete Scala Concurrent Program Using Future with Work Done Asynchronously
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/** * This program expects a text file containing the word "computation" * in the directory C:\tmp. The file name is expected to be "myText.txt" */ source.toSeq.indexOfSlice("computation") } println(n); } println(t.getMessage()) } // block at this point for the future computation to complete Await.ready(firstOccurrence, Duration("1000 seconds")) }