I came across the scala.concurrent.blocking
method, and according to the Scala documentation this is...
Used to designate a piece of code which potentially blocks, allowing the current BlockContext to adjust the runtime's behavior. Properly marking blocking code may improve performance or avoid deadlocks.
I have some doubts:
- what is the factor with which new threads will be spawned?
- Is this applicable only for
scala.concurrent.ExecutionContext.Implicits.global
execution context or for user-created execution contexts as well? - What happens if I wrap any executable with
blocking {
...}
? - Any practical use case where we should use this construct.
blocking
? Should this be used only with futures(not in main thread)? – Caulis