Start New Discussion within our Software Development Community

Hello,

I am trying to work learn thread programming in C. I have my turbo C installed and its working fine. I tried to get the library "pthread.h" and relater STLport package by searching online and managed to get them and copied them in my include directory. But while compiling a simple program stated as follows, a number of errors occur. Am I installing the POSIX files in the wrong directory or is there some other way to work with threads in C. I have also checked the options->directories in C options but even that is set properly. Please do shed some light on how to configure my Turbo C to work with threads.

Thank you.

#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#define NUM_THREADS	5

void *PrintHello(void *threadid)
{
   long tid;
   tid = (long)threadid;
   printf("Hello World! It's me, thread #%ld!\n", tid);
   pthread_exit(NULL);
}

int main(int argc, char *argv[])
{
pthread_t threads[NUM_THREADS];
int rc;
long t;
for(t=0;t<NUM_THREADS;t++){
  printf("In main: creating thread %ld\n", t);
  rc = pthread_create(&threads[t], NULL, PrintHello, (void *)t);
  if (rc){
    printf("ERROR; return code from pthread_create() is %d\n", rc);
    exit(-1);
    }
  }
pthread_exit(NULL);
}

> I am trying to work learn thread programming in C.
Mmm-kay,

> I have my turbo C installed and its working fine.
You're stuck then.

> Please do shed some light on how to configure my Turbo C to work with threads.
Delete is the only config possible.

Followed by install of a modern compiler for your modern OS, trying to use a modern API.

This question has already been answered. Start a new discussion instead.