/*
 * Criação de uma nova thread, com envio de valor de retorno.
 * Para simplificação, o apontador pode usado como inteiro.
 */
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>

void* f_thread(void *v) {
  int thr_id = *(int *) v;

  printf("Thread %d.\n", thr_id);
  return (void*) thr_id;
}

int main() {
  pthread_t thr;
  int thr_id = 1;
  void* r_id;

  pthread_create(&thr, NULL, f_thread, (void*) &thr_id);
  pthread_join(thr, &r_id);

  printf("Valor de retorno %d.\n", (int) r_id);
  return 0;
}