Scala is a JVM-based language, so programs written in Scala run in JVM. JVM, as we already know, is Java Virtual Machine, and runs as a single process in our operating system. In JVM, one of the basic concurrency constructs is a thread; we can create/use multiple threads as part of our Scala program. So, for a basic understanding of processes and threads, let's go through them.
Think of a process as a program or application that our computer might have to run. This process is going to have some code that's executable, a process identifier (pid), and at least one thread of execution. The process might consume some computer resources as well, such as memory. Every process isolates itself from other processes when it comes to consume memory; this means two processes cannot use the same memory block.
Modern computers come with multiple processor cores. These cores are assigned tasks as executable program parts for execution in certain...