EmbLogic's Blog

Algo for creating threads………

1)In the main,declare a pthread_t type variable.

2)Create a thread using pthread_create.

prototype:pthread_create(pthread_t*,attributes,void*(function pointer),void*(argument to be passed)); //attributes=0:::if not used

3)Make a function of return type void *;

4)This function would be called as soon as the thread is created.

5)Use pthread_exit() at the end of this function.

6)In the main function use pthread_join,so that the main program waits till the exit value is not captured from pthread_exit();

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>