19 lines
568 B
C
19 lines
568 B
C
|
#include<pthread.h>
|
||
|
#include<stdio.h>
|
||
|
|
||
|
void* run (void* arg){
|
||
|
printf("Hello from run\n");
|
||
|
return NULL;
|
||
|
}
|
||
|
|
||
|
int main(){
|
||
|
pthread_t thread;
|
||
|
pthread_create(&thread, NULL, &run, NULL);
|
||
|
pthread_detach(thread);
|
||
|
// This command will make thread detached. This means the resources will be released
|
||
|
// upon the thread's completion - calling return
|
||
|
// However, detached threads cannot be joined, which means if you care about the result
|
||
|
// of the thread execution - you should not be using pthread_detach
|
||
|
printf("In main");
|
||
|
return 0;
|
||
|
}
|