Share your knowledge at the LQ Wiki.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 10-29-2003, 09:47 AM   #1
LQ Newbie
Registered: Oct 2003
Posts: 28

Rep: Reputation: 15
help needed here...

why it never reach the second thread?

void fireInTheHole(void);
static int accnt1, accnt2;

int main(){

pthread_t thread1, thread2;
pthread_create(&thread1, NULL, (void*)fireInTheHole, NULL);
pthread_create(&thread2, NULL, (void*)fireInTheHole, NULL);

printf("Thread join\n:");
pthread_join(thread1, NULL);
pthread_join(thread2, NULL);

return 0;

void fireInTheHole(){
int counter = 0;
int tmp1, tmp2, r;
do {
tmp1 = accnt1;
tmp2 = accnt2;
r = rand();
accnt1 = tmp1 + r;
accnt2 = tmp2 - r;
counter ++;
} while (accnt1 + accnt2 == 0);

printf("Stopped w/ counter value: %d\n", counter);
printf("accnt1 = %d\naccnt2 = %d\n", accnt1,accnt2);
Old 10-29-2003, 10:55 AM   #2
jim mcnamara
Registered: May 2002
Posts: 964

Rep: Reputation: 36
Are you talking about pthread_join?
Old 10-29-2003, 11:59 AM   #3
LQ Newbie
Registered: Oct 2003
Posts: 28

Original Poster
Rep: Reputation: 15


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
help needed sailu_mvn Programming 2 03-24-2005 07:50 AM
Help needed! =) kith Linux - General 14 02-10-2004 01:44 PM
help needed with QT sabeel_ansari Programming 1 01-21-2004 03:14 PM
C++ help needed sabeel Programming 6 11-27-2003 01:19 PM
Needed Help rajesh.s Linux - Hardware 0 12-17-2002 03:18 AM > Forums > Non-*NIX Forums > Programming

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

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