CS3413/Lab3/examples/1-no_join-fixed.c
2023-10-04 18:07:09 -03:00

17 lines
510 B
C

/**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;
}