1. Introduction to thread in Linux


What is thread?
    Thread is the independent piece of code executed parallel y when main program executed. 

Why Thread ?
    Consider you are creating student report program in C, It should contain number of students written final exam, and their name and total mark. 

What actually you do?
Answer is this . You will write main program which find number of students, list their name and total mark. So step by step you do.

But if you use thread, 
main program list students name and total mark. same time thread will find total number of students. So we can save some time if we use thread. 

Threading is an example of parallel programming.

Working environment :
    Here used pthread (POSIX standard thread) library under Ubuntu(Linux).
    gcc compiler used to compile the program

Compilations : 
   There is need to add pthread linker when compiling thread program with the help of gcc compiler.
gcc -o <output> <input.c> -lpthread 

No comments:

Post a Comment