Showing posts with label Object Oriented Programming Methodolgy (OOPM). Show all posts
Showing posts with label Object Oriented Programming Methodolgy (OOPM). Show all posts

Difference between Process and Thread. Thread vs Process.


Thread Process
An executing instance of a program is called a process. A thread is a subset of the process.
Thread shares the address space of process that they are belonging to. Processes have their own address space.
Threads have direct access to the data segment of its process. Processes have their own copy of data segment of a parent process.
Threads can directly communicate with other threads of its process. The processes must use interprocess commumnication (IPC) to communicate with other process.
Threads have less overhead with context switching. Processes have considerable overhead.
New threads can be easily created. New process requires duplications of a parent process.
Threads can exercise a considerable control over threads of a same process. Process can only exercise control over its child process.
Changes to the main thread may affect the behaviour of other threads of a process. Changes to the process does not affect the child process.
Threads (of the same process) run in a shared memory space. Processes run in separate memory spaces.
Every thread is not a process. It is a part(entity) of a process. Every process is a thread (primary thread).
Threads are light weight processes. Threads are bundled inside the process. Process is a heavy weight process.
Threads are created using clone() method. Process are created using fork() method.

Difference between Process based vs Thread based


Process based Thread based
Heavy weight task. Light weight task.
Multiple programs executed. One program having multiple threads running concurrently.
They are different programs so share different address spaces. Share the same address space.
Context switching requires more overhead. Context switching occurs within the program so less overhead.

Difference between Interface vs Abstract Class


Interface Abstract Class
Multiple Inheritance is possible, a class can implement more than one number of interface. A class can inherit only one class.
'Implements' keyword is used. 'Extends' keyword is used.
For interface by default methods are public and abstract, no need to specify. They have to be declare as public or abstract.
No implementation of methods. Can have concrete as well as abstract methods.
All methods have to be overridden. Only abstract methods have to be overridden.
All variables are public, static and final. In abstract, variables have to be declare explicitly.
Methods can't be static. Non-abstract methods can be static.