You are using the same stack variable for all your threads (char
str[80]). Therefore, after the lest 'sprintf(str,"ticker %d",i);'
each thread prints `thread 9__'. The correct version of the
program would be:
#include <stdlib.h>
#include <stdio.h>
#include <pth.h>
#include <string.h>
void *
ticker (void *s)
{
int i;
for (i = 0;; i++)
{
printf ("%s__%i\n", (char *) s, i);
pth_usleep (100000);
}
}
int
main (int argc, char argv[][])
{
pth_attr_t attr[10];
int i;
pth_t pth[10];
char str[80];
pth_init ();
for (i = 0; i < 10; i++)
{
attr[i] = pth_attr_new ();
sprintf (str, "ticker %d", i);
pth_attr_set (attr[i], PTH_ATTR_NAME, str);
pth_attr_set (attr[i], PTH_ATTR_STACK_SIZE, 80 * 1024);
pth_attr_set (attr[i], PTH_ATTR_JOINABLE, FALSE);
pth[i] = pth_spawn (attr[i], ticker, (void *) strdup(str));
pth_usleep (100000);
}
while (1)
pth_sleep (1);
}
Regards,
Sergey
______________________________________________________________________
GNU Portable Threads (Pth) http://www.gnu.org/software/pth/
User Support Mailing List [EMAIL PROTECTED]
Automated List Manager (Majordomo) [EMAIL PROTECTED]