I want to know if thread1, calls a class function via passed object 'obj->fun()' and that object is deleted in the background by some other thread say thread2 what happens to function execution by thread1.
Example:
ClassA {
int functionA() {
...condition(started_execution);
int a=0;
a++;
printf(....a);
return a;
}
};
void startExecution(void *arg) {
/*casting code object A*/
A->functionA();
}
int main() {
ClassA *A = new ClassA();
pthread_create(....,startExecution,(void *)A);
....wait_for(started_execution);
delete A;//just want to know the behaviour and not join method.
}
Question: In the above scenario, A->functionA calls function functionA. If the function is executing, what will the impact of delete A on function execution since object A invoked it? functionA is not working on shared data?