CS3413/Assignment3/examples/2-sleep no_join-fixed.c

24 lines
563 B
C
Raw Normal View History

2023-10-08 23:19:49 -03:00
#include<pthread.h>
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<time.h>
#include<sys/time.h>
void* run (void* arg){
printf("Hello from run\n");
return NULL;
}
int main(){
pthread_t thread;
pthread_create(&thread, NULL, &run, NULL);
// While the sleep() function will appear to provide synchronization,
// it is incorrect, and if used for this purposes instead of join
// or synchronization mechanism - the grade for the assignment will be
// reduced
sleep(2);
printf("Back in main");
return 0;
}