As I know threads share the memory. But, what about the local variables in the thread function? if i call multiple threads would they allocate seperate local variables for themselves?
like
thread_func()
{
int i, j;
string...
}
Are the above local variables defined for each of the threads? in that case if i call threads simultaneously, their local variables will not conflict
Every thread has its own stack. Hence, in your example, i and j would be hence "private to the threads" and thus their local variables "would not conflict".
Of course, if another thread happens to know the address of variable i (or j) of a thread, it may access/modify it. But that's not an usual pattern.