私はマルチスレッド化のためにC++とpthreadを使用しています。私は作成呼び出しの順にスレッドを実行したい。実行順にpthreadを作成
retrnThread=pthread_create(&thread_id,NULL,&HandleNotifications,(void*)Status);
上記のコードでは、コードは非常に短時間で3〜4回実行され、スレッドはランダムな順序で実行されます。私は作成されたのと同じ順序でスレッドの実行をしたい。
retrnThread=pthread_create(&thread_id,NULL,&HandleNotifications1,(void*)Status);
retrnThread=pthread_create(&thread_id,NULL,&HandleNotifications2,(void*)Status);
retrnThread=pthread_create(&thread_id,NULL,&HandleNotifications3,(void*)Status);
retrnThread=pthread_create(&thread_id,NULL,&HandleNotifications4,(void*)Status);
実行順序は次のようになります。 HandleNotifications1 HandleNotifications2 HandleNotifications3 HandleNotifications4
ここでは、すべてのスレッドが互いに独立しています。私は彼らに参加するか、またはそれらを同期させる必要はありません。
_「参加する必要はありません。」_スレッドを特定の順序で実行したい場合は、実行する必要があります。 –
同時に実行できない場合、4つのスレッドを作成する際のポイントは何ですか?通知を順番に処理するスレッドを1つ作成します(スレッドが必要な場合)。 – Mat