Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Stwórz w programie dwa wątki, które wypiszą swój identyfikator i identyfikator procesu.
- */
- #include <stdio.h>
- #include <stdlib.h>
- #include <pthread.h>
- #include <unistd.h>
- void *first_thread_func()
- {
- printf("Watek 1: Id watku: %lu Id procesu: %d\n", pthread_self(), getpid());
- return EXIT_SUCCESS;
- }
- void *second_thread_func()
- {
- printf("Watek 2: Id watku: %lu Id procesu: %d\n", pthread_self(), getpid());
- return EXIT_SUCCESS;
- }
- int main(void)
- {
- pthread_t first_thread, second_thread;
- pthread_create(&first_thread, NULL, first_thread_func, (void *)0);
- pthread_create(&second_thread, NULL, second_thread_func, (void *)0);
- pthread_join(first_thread, NULL);
- pthread_join(second_thread, NULL);
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment