LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   to write threads (https://www.linuxquestions.org/questions/programming-9/to-write-threads-554018/)

munna_dude 05-15-2007 06:34 AM

to write threads
 
hi all
i have a doubt.
i wrote a program using threads.
i used threads like this
void one()
{
pthread_t thread;
gint iret1;
iret1=pthread_create( &thread, NULL, two, NULL);
}
void two()
{
printf("enterd in to thread \n");
three();
pthread_exit(0);
}

void three()
{
printf("hiiiiiiii \n");
}

can you tell is this wright way to use threads.


help me thank you in advance

Guttorm 05-15-2007 06:55 AM

Hi

It's not easy to say from the code you posted. I learned about this not so long ago. One place I found good information was:

http://en.wikipedia.org/wiki/Pthreads

Look in the "External links" sections. There are some tutorials and examples, and if you follow the links, you can get even more tutorials and examples. I got a multithreaded program working by reading that stuff.

bigearsbilly 05-15-2007 07:08 AM

from http://www.faqs.org/docs/artu/
The Art of Unix Programming
Eric Steven Raymond
Quote:

From a complexity-control point of view, threads are a bad substitute for lightweight processes with their own address spaces; the idea of threads is native to operating systems with expensive process-spawning and weak IPC facilities.
Stevens says a very similar thing


All times are GMT -5. The time now is 01:54 PM.