When I start some Scala Futures that perform expensive computations, the main thread starts to lag very badly. I don't use any callbacks just plain:
//got global execution context
for(i <- 0 until NUMBER_OF_FUTURES){
Future{do_work()}
}
What causes the freezes ?
EDIT: Maybe execution context allows to run Futures on the main thread ?
EDIT2 Execution context I'm using:
private implicit val ec = new ExecutionContext
{
val threadPool = Executors.newSingleThreadExecutor()
def execute(runnable: Runnable) {
threadPool.submit(runnable)
}
def reportFailure(t: Throwable) {}
}