Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <pthread.h>
- #include <stdio.h>
- #include <unistd.h>
- void *threadFunc(void *arg)
- {
- char *str;
- int i = 0;
- str=(char*)arg;
- while(i < 110)
- {
- usleep(1);
- printf("threadFunc says: %s\n",str);
- ++i;
- }
- return NULL;
- }
- int main(void)
- {
- pthread_t pth; // this is our thread identifier
- int i = 0;
- pthread_create(&pth,NULL,threadFunc,"foo");
- while (i < 100)
- {
- usleep(1);
- printf("main is running...\n");
- ++i;
- }
- printf("main waiting for thread to terminat...\n");
- pthread_join(pth,NULL);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement