LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-15-2007, 06:34 AM   #1
munna_dude
Member
 
Registered: Dec 2006
Posts: 362

Rep: Reputation: 30
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
 
Old 05-15-2007, 06:55 AM   #2
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,450

Rep: Reputation: 446Reputation: 446Reputation: 446Reputation: 446Reputation: 446
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.
 
Old 05-15-2007, 07:08 AM   #3
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to write multiple threads working simultaneously ? indian Programming 3 09-19-2011 11:41 PM
"Find all threads started by user" not showing all threads Nylex LQ Suggestions & Feedback 3 12-28-2005 08:28 PM
Java threads listed using kill -3 does not contain all threads found using ps -auxww coneheed Programming 2 11-14-2005 08:57 AM
Java Threads vs Native Threads rjmendez Programming 0 08-16-2004 05:58 AM
how to write a program can have 2 threads running at the same time?? man9 Programming 3 10-07-2000 01:43 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:10 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration