Here’s the table comparing processes and threads:
Parameter | Process | Thread |
---|---|---|
Definition | Program in execution. | Separate path of execution in a program. One or more threads make up a process. |
Weight | Processes are heavyweight. | Threads are lightweight. |
Address Space | Processes require separate address space. | Threads share the same address space. |
Communication | Interprocess communication is expensive. | Interthread communication is less expensive compared to processes. |
Context Switching | Context switching from one process to another is costly. | Context switching between threads within the same process is relatively faster. |
Java Interview Questions with Answers (2023)