Each process has a single piece of memory space, and an application can start multiple processes at the same time. Like a browser, opening a browser is equivalent to starting a process.
A thread refers to an execution process in a process that can contain multiple threads.
Each process requires the operating system to allocate a separate memory space, and multiple threads in the same process share the space, that is, resources such as shared memory.
. Advantages and Disadvantages
Threads and processes have advantages and disadvantages in use:
The thread execution cost is small, but it is not conducive to the management and protection of resources;
And the process is the opposite.
At the same time, threads are suitable for running on SMP machines, while processes can be migrated across machines.
Note:SMP is (symmetrical multi-processing) shorthand, usually referred to as the dual CPU system, is actually the most common symmetric multiprocessor system, commonly known as 2-way symmetric multi-processing.
The difference between a Java process and a thread