In simple words pthread_join makes the calling thread wait till the newly created thread returns. How this helps?
Thread-safety of a function refers to the fact whether a function can be safely called from multiple threads simultaneously. Safety here means that even if multiple threads are executing the function simultaneously the data integrity is intact and is not intermingled.
What is memory leak?
Memory leak is a phenomenon where a running C/C++ program or a running process or thread dynamically allocates memory block from the heap but fails to free the memory block when it no more requires the memory. This happens due to programmatic error where the handle to the allocated memory block gets lost.