a(es) submits a Callable to the ExecutorService when a is a forked Par. If you only have one thread available, and that thread is running the outer Callable submitted to the ExecutorService, then as soon as it calls .call() it is going to block waiting for a thread to be available. Therefore the only thread will be sitting and waiting for another thread. This is a deadlock.
See Example 7.8
: A => Par[B]in the asyncF definition means
A => Par[B]is syntax sugar for
We are currently working through Chapter 7 and we realized that on page 99: it states that
Par.get(Par.unit(sum(l))) + Par.get(Par.unit(sum(r))) breaks referential transparency. However, the book also states in the line above the chunk of code that we do get the same result. As such, we were wondering why the program breaks referential transparency as the book define referential transparency on chapter 1, page 10 as
any program, the expression can be replaced by its result without changing the meaning of
the program. Does meaning include parallelism as well? Any insights would be greatly appreciated.