/****************************************************************
 *                                                              *
 *  LIBDIST V1.0						*
 *                                                              *
 *  thread-test.c -- test thread handling routines              *
 *                                                              *
 *  Last changed: 19.02.96                                      *
 *  Author: Frank Kargl (frank.kargl@informatik.uni-ulm.de)     *
 *                                                              *
 *  Restrictions: works only for Solaris 2.6 or above           *
 *                                                              *
 ****************************************************************/

#include "libdist.h"
#include "config.h"

/* routine to be called by thread */
void *threadrun(void *string) {

	while(1) {
		printf("I have been called with arg %s\n",(char *)string);
		sleep(5);
	}
	dl_thr_exit();
	return (void *)NULL;
}

int main() {
	
	thread_t mythread1,mythread2;	/* thread id */

	/* create threads */
	mythread1 = dl_thr_create(threadrun,(void *)"Argument1");
	mythread2 = dl_thr_create(threadrun,(void *)"Argument2");

	printf("mythread1 = %d\n",mythread1);
	printf("mythread2 = %d\n",mythread2);

	sleep(60);
	
	/* stop threads */
	dl_thr_kill(mythread1,SIGKILL);
	dl_thr_kill(mythread2,SIGKILL);

	sleep(5);

	return 0;
}
