#include <stdio.h> #include <pthread.h> #include <stdlib.h> #include <string.h> char a[]="Hello"; void * thread_body(void * param) { while(1) printf("%s\n", param); } int main(int argc, char *argv[]) { pthread_t threadHello; int code; pthread_create(&threadHello, NULL, thread_body, a); pthread_cancel(threadHello); pthread_exit(0); }
When I compile and run it under Solaris 10 (SunOS 5.10), it does not stop. But under Linux, it works as intended.
source share