A process is an instance of a computer program that is being executed. It contains the program code and its current activity. Depending on the operating system (OS), a process may be made up of multiple threads of execution that execute instructions concurrently. Process-based multitasking enables you to run the Java compiler at the same time that you are using a text editor. In employing multiple processes with a single CPU, context switching between various memory context is used. Each process has a complete set of its own variables.
A thread of execution results from a fork of a computer program into two or more concurrently running tasks. The implementation of threads and processes differs from one operating system to another, but in most cases, a thread is contained inside a process. Multiple threads can exist within the same process and share resources such as memory, while different processes do not share these resources. Example of threads in same process is automatic spell check and automatic saving of a file while writing. Threads are basically processes that run in the same memory context. Threads may share the same data while execution.
A task is a set of program instructions that are loaded in memory. The states of a task are as shown in the figure below. The states are idle state, ready state, running state and blocked state. The idle state is the state of the task when it is just created. Once it is attached to the kernel, it enters into ready state, i.e. it has all the resources required for its execution. In the multi-tasking system, the OS schedules the task by either giving it a signal or a message, that causes the task to enter into the running state. In case if there is unavailability of a resource or the task has to wait for a signal or message, the task enters into the blocked state. If the task is in blocked state for long time, it enters into idle state. In case if the task gets the signal or message for which the task was waiting then the task enters again into running state from the blocked state.