/*---------------------------------------------------------------------------*/
#include <stdio.h>
#include <pthread.h>
pthread_t NewThread;
/*---------------------------------------------------------------------------*/
void *StartHere(void *Message) {
if (pthread_equal(NewThread,pthread_self())) {
printf("%s\n",(char *)Message);
}
return(NULL);
}
/*---------------------------------------------------------------------------*/
int main(int argc,char *argv[]) {
pthread_create(&NewThread,NULL,StartHere,"Hello There");
StartHere("Hello");
StartHere("There");
pthread_exit(NULL);
}
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
#include <stdio.h>
#include <pthread.h>
pthread_cond_t GunShot;
pthread_mutex_t Mutex;
/*---------------------------------------------------------------------------*/
void *LookAndLeap(void *Dummy) {
pthread_mutex_lock(&Mutex);
printf("Wild\n");
pthread_cond_wait(&GunShot,&Mutex);
printf("West!!\n");
return(NULL);
}
/*---------------------------------------------------------------------------*/
int main(int argc,char *argv[]) {
pthread_t NewThread;
pthread_cond_init(&GunShot,NULL);
pthread_mutex_init(&Mutex,NULL);
pthread_create(&NewThread,NULL,LookAndLeap,NULL);
pthread_create(&NewThread,NULL,LookAndLeap,NULL);
sched_yield();
printf("Woolly\n");
pthread_cond_broadcast(&GunShot);
pthread_exit(NULL);
}
/*---------------------------------------------------------------------------*/