In the below line
pthread_create(&threads[i], NULL, PrintHello, (void *)&td[i]);
the first argument is not passed by reference (in
C++
you must NOT use the
&
operarator in a call by-reference). It is instead the
address (i.e.
pointer to) of a
pthread_t
variable (namely it is the address of the
threads[i]
, that is the i
th item of the array
threads
) as required by the
pthread_create[
^] function.