proxy-ftp/thread/main.c

55 lines
721 B
C
Raw Normal View History

2015-12-14 20:48:19 +00:00
#include <stdlib.h>
#include <stdio.h>
#include <pthread.h>
#include <string.h>
static void* action1();
static void* action2();
pthread_t thread1, thread2;
static int bool1 = 1;
static int bool2 = 1;
int main(int argc, char* argv []){
pthread_create(&thread1, NULL, &action1, (void*) NULL);
pthread_create(&thread2, NULL, &action2, (void*) NULL);
printf("THREADS CREATED\n===============\n");
sleep(3);
bool1 = 0;
sleep(3);
bool2 = 0;
return EXIT_SUCCESS;
}
static void* action1(){
while( bool1 ){
printf("[THREAD] 1\n");
sleep(1);
}
pthread_exit((void*) thread1);
}
static void* action2(){
while( bool2 ){
printf("[THREAD] 2\n");
sleep(1);
}
pthread_exit((void*) thread2);
}