Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <fcntl.h>
- #include <pthread.h>
- #include <string.h>
- #include <sys/file.h>
- #include <stdlib.h>
- #include <stdio.h>
- #include <unistd.h>
- #include <time.h>
- void *fun_watek1(void * p);
- void *fun_watek2(void * p);
- char* message;
- pthread_attr_t attr;
- int main() {
- pthread_t watek1;
- pthread_t watek2;
- pthread_attr_init(&attr);
- pthread_create(&watek1, &attr, fun_watek1, (void *)&message);
- pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
- pthread_create(&watek2, &attr, fun_watek2, (void *)&message);
- pthread_join(watek1, NULL);
- //tu
- pthread_join(watek2, NULL);
- pthread_attr_destroy(&attr);
- return0;
- }
- void *fun_watek1(void * p) {
- printf("Watek 1: %lu, PID: %d\n", pthread_self(), getpid());
- return0;
- }
- void *fun_watek2(void * p) {
- printf("Watek 2: %lu, PID: %d\n", pthread_self(), getpid());
- return0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement