
The 25 lines of code are as follows.
hash include open angle bracket pthread.h close angle bracket
hash include open angle bracket stdio.h close angle bracket
hash include open angle bracket stdlib.h close angle bracket
hash define NUMBER under score OF under score THREADS 10
void asterisk print under score hello under score world open parenthesis void asterisk tid close parenthesis
open curly bracket
forward slash asterisk This function prints the thread's identifier and then exits. asterisk forward slash
printf open parenthesis double quote Hello World. Greetings from thread percent d backward slash n double quote coma tid close parenthesis semi colon
pthread under score exit open parenthesis NULL close parenthesis semi colon
close curly bracket
int main open parenthesis int argc coma char asterisk argvopen close box bracket close parenthesis
open curly bracket
forward slash asterisk The main program creates 10 threads and then exits. asterisk forward slash
pthread under score t threadsopen box bracket NUMBER under score OF under score THREADSclose box bracket semi colon
int status coma i semi colon
for open parenthesis i equals to 0 semi colon i less than NUMBER under score OF under score THREADS semi colon i plus plus close parenthesis open curly bracket
printf open parenthesis double quote Main here. Creating thread percent d backward slash n double quote coma i close parenthesis semi colon
status equals to pthread under score create open parenthesis &threadsopen box bracket i close box bracket coma NULL coma print under score hello under score world coma open parenthesis void asterisk close parenthesis i close parenthesis
if open parenthesis status exclamation mark equals to 0 close parenthesis open curly bracket
printf open parenthesis double quote Oops. pthread under score create returned error code percent d backward slash n double quote coma status close parenthesis semi colon
exit open parenthesis negative 1 close parenthesis semi colon
close curly bracket
close curly bracket
exit open parenthesis NULL close parenthesis semi colon
close curly bracket
Back