#include <stdio.h>
#include <pthread.h>

void *
hello (void * arg)
{
	printf ("\t\tHello world : %d\n", *((int *)arg));
	return NULL;
}

void
main (int argc, char ** argv)
{
	pthread_t th1, th2;
	int n1 = 1, n2 = 2;
	int status;

	status = pthread_create (&th1, NULL, hello, &n1);
	if (status == -1)
	{
		fprintf (stderr, "FAIL: %s (%s)\n", argv [0], strerror (status));
		exit (1);
	}
	else /* Join */
	{
		status = pthread_join (th1, NULL);
		if (status == -1)
		{
			fprintf (stderr, "FAIL: %s (%s)\n", argv [0], strerror (status));
			exit (1);
		}
	}

	status = pthread_create (&th2, NULL, hello, &n2);
	if (status == -1)
	{
		fprintf (stderr, "FAIL: %s (%s)\n", argv [0], strerror (status));
		exit (1);
	}
	else
	{
		status = pthread_join (th2, NULL);
		if (status == -1)
		{
			fprintf (stderr, "FAIL: %s (%s)\n", argv [0], strerror (status));
			exit (1);
		}
	}

	printf ("PASS: %s\n", argv [0]);
	exit (0);
}
