A thread is a single flow of control within a program.Thread is very much similar to a process.In fact thread is also called light-weight process.
pthread_create : Create a new Thread
Syntax: int pthread_create(pthread_t *thread,const pthread_attr_t *attr,void *(*start routine) (void*),void *arg)
Description:
The pthread_create() function starts a new thread in the calling process.The new thread stars execution by invoking start routine();
arg is passed as the sole argument of start routine().
Return Value:
On success pthread_create() return 0,On error it returns an error.
How to run programe of Thread:
gcc filename.c -o f1 -lpthread (for execution of programe)
./ f1 (to run programe)
where f1 is executable file name
Note: we can also run this programe as
gcc filename.c -lpthread(for execution)
./a.out(to run programe)
No comments:
Post a Comment