All pastes #543859 Raw Edit

Something

public text v1 · immutable
·published 2007-06-06 06:32 UTC
rendered paste body
#include <pthread.h>
#include <stdlib.h>
#include <unistd.h>

void *thread_function(void *arg) {
  int i;
  for ( i=0; i<20; i++ ) {
    printf("Thread %d says hi!\n",i+1);
    sleep(1);
  }
  return NULL;
}

int main(void) {

  pthread_t mythread;
  
  if ( pthread_create( &mythread, NULL, thread_function, NULL) ) {
    printf("error creating thread.");
    abort();
  }

  if ( pthread_join ( mythread, NULL ) ) {
    printf("error joining thread.");
    abort();
  }

  exit(0);

}





gonzalo@gaf1~/progs/so/pc4$ cc -o thread.1 thread1.c -lpthread
thread1.c: In function 'thread_function':
thread1.c:8: warning: incompatible implicit declaration of built-in function 'printf'
thread1.c: In function 'main':
thread1.c:19: warning: incompatible implicit declaration of built-in function 'printf'
thread1.c:24: warning: incompatible implicit declaration of built-in function 'printf'