Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <pthread.h>
- #include <stdio.h>
- #define MAX_THREADS 3
- void * ex(void * data) {
- pthread_exit(NULL);
- return NULL;
- }
- int main(int argc, char * argv[]){
- int rc;
- pthread_t thread_id[MAX_THREADS];
- int i;
- for(i = 0; i < MAX_THREADS; i++){
- rc = pthread_create(&thread_id[i], NULL, ex, (void*)i);
- if(rc){
- printf("\n ERROR: El codi retornat és %d \n", rc);
- exit(-1);
- }
- printf("\n pthread_self (%d). Sóc el thread %d creat a la iteracció %d ...\n", pthread_self(), thread_id[i], i);
- sleep(1);
- }
- pthread_exit(NULL);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement