For me, the main problem that you will encounter is that any call to a synchronized or blocked section of code can block and thus paralyze execution context threads. To avoid this problem, you can bind any call to a potentially blocking method using scala.concurrent.blocking :
import scala.concurrent._ import ExecutionContext.Implicits.global def synchronizedMethod(s: String) = synchronized{ s.size } val f = future{ println("Hello") val i = blocking{
Of course, it might be better to consider alternatives, such as streaming local variables or transferring a call to serial code inside an actor.
Finally, I suggest using synchronization instead of locks. For most applications (especially if critical sections are huge) the performance difference is not noticeable.
source share