Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // multiplas tarefas (thread)
- // Apple Xcode
- // paulogp
- #include <stdio.h>
- #include <time.h>
- #include <pthread.h>
- void *print_xs(void *unused)
- {
- while (1)
- {
- fputc('x', stderr);
- }
- return NULL;
- }
- int main (int argc, const char * argv[])
- {
- pthread_t the_thread_id;
- // cria uma thread para executar print_xs em
- // simultaneo com a funcao main
- pthread_create(&the_thread_id, NULL, print_xs, NULL);
- // nao queremos esperar pela conclusao da thread
- pthread_detach(the_thread_id);
- // while (1) infinite loop
- for (int i = 0; i < 10000; i++)
- {
- fputc('o', stderr);
- }
- printf("\n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement