You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/* This program must be linked with the thread lib when compiling*/
/* Give function & run it in a separate thread */
/* Entire process gets forked from that process onwards while in pthread we name a func which will run as a context of a thread */
/* parent & thread have both same pid & ppid
*ps -elf | grep ./pthread
* */
void *ThreadFunc(void *args)
{
int i;
for(i=0;i<25;++i)
{
printf("This is from thread i=%d\n", i);
sleep(1);
}
}
int main()
{
pthread_t mythread;
void *thread_result;
int j=0;
/* Pass the ref to the thread | thread attributes/ way to start/ initialization with semapthore/ conditionals | start_routine:the thread func above -> creates a container(with functions to be executed) | Arguments to pass(like func) */