/* * Criação de uma nova thread, com envio de valor de retorno (endereço * de variável alocada dinamicamente). */ #include #include #include void* f_thread(void *v) { int *retorno = (int *) malloc (sizeof(int)); printf("Nova Thread irá retornar 256.\n"); *retorno = 256; return (void*) retorno; } int main() { pthread_t thr; int* retorno_thr; pthread_create(&thr, NULL, f_thread, NULL); pthread_join(thr, (void**) &retorno_thr); printf("Valor de retorno: %d\n", *retorno_thr); free(retorno_thr); return 0; }