On the OS level there are two most common units of execution:
A process has a self-contained execution environment. In particular, it has its own memory space!
It takes longer to set up and it is usually a synonym for program/application.
Processes can communicate via Inter Process Communication (IPC) protocols supported by the OS. These are
The JVM is, in general, a single process.
We can understand a thread as a "lightweight process".
Threads exist within a process and every process has at least one thread.
Threads share the process's resources, including memory and open files. Because of that, creating a new thread requires fewer resources than creating a new process.
In Java, a program starts with a single thread, the main thread, but can create new ones.
In Java, the life cycle of a thread is controlled by the JVM.
We distinguish between two thread types.
User threads
Daemon threads: