2
PROGRAM CODE #include <pthread.h> #include <stdlib.h> #include <unistd.h> #include <stdio.h> void *thread_function(void *arg) { int i,tid; tid=pthread_self(); for ( i=0; i<2; i++ ) { printf("Thread with id %d says Hi!\n",tid); sleep(1); } return NULL; } int main(void) { pthread_t mythread1,mythread2; if ( pthread_create( &mythread1, NULL, thread_function, NULL) ) { printf("error creating thread!"); abort(); } if ( pthread_create( &mythread2, NULL, thread_function, NULL) ) { printf("error creating thread!"); abort(); } if ( pthread_join ( mythread1, NULL ) ) { printf("error joining thread!"); abort();

progm7

Embed Size (px)

DESCRIPTION

program

Citation preview

PROGRAM CODE#include

#include

#include

#include

void *thread_function(void *arg) {

int i,tid;

tid=pthread_self();

for ( i=0; i