Subj : Re: passing an 'int' to a thread To : comp.programming.threads From : ptjm Date : Wed Jun 08 2005 06:28 am In article <42a671a3$0$156$3a628fcd@reader2.nntp.hccnet.nl>, Huub wrote: % You were right. The errors were due to a linking problem. And I made a % another mistake which I corrected. Now something is being passed, but % it's not the correct value. Could you tell me what is being passed: % task_ids or t? You're passing a pointer to int which is set to 0. This pointer is held in an array called task_ids, but you're not passing that array. It has the value of a variable called t, but you're not passing that variable. Note that if you change the value of t, your code will be incorrect. [...] % int *task_ids[1]; [...] % task_ids[t] = (int *) malloc(sizeof(int)); % *task_ids[t] = t; You never use task_ids for anything else, so why not store the pointer in an ordinary pointer variable. int * task_id ; ... task_id = (int *)malloc(sizeof(int)); /* or new(int) */ *task_id = value; pthread_create(&tid, NULL, fn, (void *)task_id); -- Patrick TJ McPhee North York Canada ptjm@interlog.com .