37 lines
643 B
C
37 lines
643 B
C
#include <stdio.h>
|
|
|
|
#include <pthread.h>
|
|
#include <unistd.h>
|
|
|
|
/*
|
|
pthread_t phread_self(void);
|
|
|
|
void * start_routine(void * arg);
|
|
int pthread_create(pthread_t * thread, const pthread_attr_t * attr,
|
|
void *(start_routine)(void *), void * arg);
|
|
void pthread_exit(void *retval);
|
|
*/
|
|
|
|
void * start_routine(void * arg) {
|
|
int pid = pthread_self();
|
|
printf("%d\n",pid);
|
|
return NULL;
|
|
}
|
|
|
|
int main() {
|
|
|
|
int val1 = 5;
|
|
int val2 = 11;
|
|
|
|
pthread_t thread1;
|
|
pthread_t thread2;
|
|
pthread_create(&thread1, NULL, &start_routine, NULL);
|
|
pthread_create(&thread2, NULL, &start_routine, NULL);
|
|
|
|
|
|
|
|
printf("Program started!\n");
|
|
|
|
pthread_exit(NULL);
|
|
return 0;
|
|
} |