#include<pthread.h>
#include<stdio.h>

void* run (void* arg){
    int i = (int) arg;
    printf("Hello from run, arg is %i\n",i);
}

int main(){
    pthread_t thread[10];
    int i = 0;
    for (i = 0 ; i < 10; ++i)
        pthread_create(&thread, NULL, &run,(void*)i);
    // Notice how warnings are generated. This can be resolved by properly
    // allocating space for the thread parameters.
    // Note, that if you are using stack variable, the values might be corrupted
    for (i = 0 ; i < 10; i++){
        pthread_join(thread[i],NULL);
    }
    printf("In main");
}