A thread is basically a path of execution through a program. It is also the smallest unit of execution. A thread consists of a stack, the state of the CPU registers, and an entry in the execution list of the system scheduler. Each thread can shares all the process's resources.
A process consists of
1. one or more threads
2. the code,
4. other resources of a program in memory.
Ex. open files, semaphores, dynamically allocated memory.
A program executes when the system scheduler gives one of its threads execution control. The scheduler determines which threads should run and when they should run. Threads of lower priority might have to wait while higher priority threads complete their tasks. On multiprocessor machines, the scheduler can move individual threads to different processors to balance the CPU load.
Each thread in a process operates independently. Unless you make them visible to each other, the threads execute individually and are unaware of the other threads in a process. Threads sharing common resources, however, must coordinate their work by using semaphores or another method of inter-process communication.