This is one of the most favorite question asked by java interviewers for freshers.
Below are 6 differences between thread and process:
1. A program in execution is called process while a thread is a subset of the process.
2. Both process and thread are independent paths of execution but a process can contain multiple threads. A thread is a smallest part of the process which can execute concurrently with other threads of the process.
3. Each process has its own separate memory space and unique process identifier(PID) while each threads inside a process share the same memory space and has its own stack which is shared with other threads.
4. A process communicate with other process by using inter-process communication which is limited and expensive while a thread can communicate with other threads directly within the same process by using inter-thread communication like wait and notify methods in java which is much simpler and cheaper than inter-process communication.
5. Process creation requires duplication of parent process while its easy to create a new thread by creating an object of Thread class and calling its start method.
6. Threads have less overhead as compared to Process in terms of metadata, context switching and memory space requirement.