I use pthread\_create to create 10 child threads, passes an integer to the thread\_func

```
#define THREAD_NUM 10

void *thread_func(void *arg)
{
    int v = (int)arg;

    printf("v = %d\n", v);

    return (void*)0;
}

int main(int argc, const char *argv[])
{
    pthread_t pids[THREAD_NUM];
    int rv;
    int i;

    for (i = 0; i < THREAD_NUM; i++) {
        rv = pthread_create(&pids[i], NULL, thread_func, (void*)i);
        if (rv != 0) {
           perror("failed to create child thread");
           return 1;
        }
    }
    return 0;
}

```

I was wondering why it outputs different result everytime not just
v = 1
v = 2
...
v = 9