multithread launching order

前端 未结 4 2008
庸人自扰
庸人自扰 2021-01-15 10:00

I have 4 threads to create thread1, thread2, thread3 and thread4:

pthread_create(thread1,NULL,thread_func1,NULL);
pthread_create(thread2,NULL,thread_func2,NU         


        
4条回答
  •  萌比男神i
    2021-01-15 10:32

    I don't think you really care which thread executed first. If you just need an unique identifier for the four threads, check pthread_self. To have sequential IDs, call the ID allocator from within the thread; or generate the ID and pass it as user parameter when calling pthread_create.

提交回复
热议问题