Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

i want to fix the solution and provide an explanation why the pthread_join is not working as intended? #include /* standard I/O routines */ #include

i want to fix the solution and provide an explanation why the pthread_join is not working as intended? #include  /* standard I/O routines */ #include  /* pthread functions and data structures */ void* PrintHello(void* data) { pthread_t tid = (pthread_t)data; /* data received by thread */ pthread_join(tid, NULL); /* wait for thread tid */ printf("Hello from new thread %u - got %u ", pthread_self(), data); pthread_exit(NULL); /* terminate the thread */ } /* like any C program, program's execution begins in main */ int main(int argc, char* argv[]) { int rc; /* return value */ pthread_t thread_id; /* thread's ID (just an integer) */ int tid; tid = pthread_self(); rc = pthread_create(&thread_id, NULL, PrintHello, (void*)tid); if(rc) /* could not create thread */ { printf(" ERROR: return code from pthread_create is %d ", rc); exit(1); } sleep(1); printf(" Created new thread (%u) ... ", thread_id); pthread_exit(NULL); }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Visual Basic6 Database Programming

Authors: John W. Fronckowiak, David J. Helda

1st Edition

0764532545, 978-0764532542

More Books

Students also viewed these Databases questions

Question

=+j Explain IHRMs role in global HR research.

Answered: 1 week ago

Question

=+j Describe an effective crisis management program.

Answered: 1 week ago