3 つの引数を渡したいスレッドがあります。したがって、次のように構造体に入れます。
struct arg
{
time_t  time1;
float name1;
time_t quantum1;
};
次の方法で引数を渡しました。
 arg arg1;
 arg1.time1=(time_t)(int)job.peek(); //job.peek() was 3
 cout<<"job time is "<<arg1.time1<<endl; //this output 3
 arg1.name1=(float)(int)job.returnname(NULL); //job.returnname() was 1
 cout<<"job name is "<<arg1.name1<<endl;// this output 1
 arg1.quantum1=quantum; //quantum was 7
 cout<<"quantum is "<<arg1.quantum1<<endl;//this output 7
 pthread_create(&thread1, NULL, func3, (void*)(&arg1));
しかし、スレッド自体の冒頭でこれらの値を確認したところ、変更されていました。
 void* timer(void *argum)
 {
 arg *arg1= (arg*)argum;
 cout<<"PROCESS "<<arg1->name1<<" HAS ENTERED THE TIMER"<<endl; //this output arg1->name1 as 1.4013e-45
 cout<<"Time remaining for process is "<<arg1->time1<<endl; //this output arg1->time1 as -1218381144
 cout<<"quantum is "<<arg1->quantum1<<endl; //this output arg1->quantum1 as 5
 }
なぜこれが起こったのか誰か教えてもらえますか?
前もって感謝します!!