S
Steven
Hello
I need some help with canceling a thread.
Here is a simple code that creates and cancels a thread. It does create a
thread BUT it doesnt cancel it, am I doing this wrong?
Thank you!
#include <pthread.h>
#include <stdio.h>
#include<iostream.h>
void* work(void* arg){ while (1); }
int main()
{
int tmp=0;
pthread_t thread;
process=pthread_create(&thread,NULL,work,NULL);
pthread_cancel(thread); // this doesnt work
cin>>tmp>>tmp;
return 0;
}
I need some help with canceling a thread.
Here is a simple code that creates and cancels a thread. It does create a
thread BUT it doesnt cancel it, am I doing this wrong?
Thank you!
#include <pthread.h>
#include <stdio.h>
#include<iostream.h>
void* work(void* arg){ while (1); }
int main()
{
int tmp=0;
pthread_t thread;
process=pthread_create(&thread,NULL,work,NULL);
pthread_cancel(thread); // this doesnt work
cin>>tmp>>tmp;
return 0;
}