use warnings; use Inline C => Config => LIBS => '-lpthread', BUILD_NOISY => 1; use Inline C => <<'EOC'; #include #include #include #include #include void *TaskCode(void *argument) { int tid; char * s; tid = *((int *) argument); printf("thread %d: calling malloc\n", tid); s = (char*) malloc(100); printf("thread %d: malloc called\n", tid); return NULL; } void demo (int NUM_THREADS) { pthread_t threads[NUM_THREADS]; int thread_args[NUM_THREADS]; int rc, i; /* create all threads */ for (i=0; i