252 Introduction to Concurrency in Programming Languages
12.1.1 Recursion and concurrency
Why did we begin this recursion refresher with a discussion of the stack
discipline? Recursion, as with all function invocations, is intimately tied to the
stack of activation records. How does this work in the context of recursive calls
that execute concurrently? If these concurrent functions themselves execute
recursive (or non-recursive) functions, where do they go on the stack? How can
a stack discipline be maintained? In practice, two approaches are encountered.
The first is based on spawning of new threads for each call. The second is
based on redefining how the stack is structured.
In the first case, a new thread of execution is created for each recursive call. ...