CS3413/Assignment3/examples/1-no_join-fixed.c

17 lines
510 B
C
Raw Normal View History

2023-10-08 23:19:49 -03:00
/**To compile, don't forget to add -lpthread. Might not work without that */
#include<pthread.h>
#include<stdio.h>
void* run (void* arg){
printf("Hello from run\n");
return NULL;
}
int main(){
pthread_t thread; // variable to store the reference to the thread
pthread_create(&thread, NULL, &run, NULL);
printf("In main"); // This section will be executed in parallel
pthread_join(thread,NULL); // necessary for waiting for the thread to finish
printf("In main 2");
return 0;
}