Java Multithreading, Concurrency, and Parallelism — Part 1
The program, Process, and a Thread
Multithreading is all about executing small tasks independently inside a process. Well, there are many articles that explain what a process, thread, and concurrency mean. Let me also specify the same in simple words here.
How a process is born?
A process takes its birth from a static file called a program that contains a specific set of instructions with its associated data. A program, being a static file residing in an auxiliary memory like a hard disk, has many extensions depending on the programming language. For example, in Java, it is a .class file or an executable .jar file that has a set of instructions telling the Operating System how to perform a task.
When we execute a program, it is loaded into the Main Memory(RAM), by the Operating System(with the concept known Paging). The Operating System’s core called Kernel then creates the process which is the running instance of a program. In simple words, the process is just the runtime instance of our program.
So What is a Thread
A thread is a small independent unit of execution inside a process. Multiple threads may exist within a process, running concurrently, having some local state associated with them. There may also be a global state in a process that all the threads share. Special care needs to be taken when multiple threads are writing and reading to and from this…