Use pointer to free_mem instead of duplicating free_mem variable
Maintain child thread structure in the list.
Add pthread_mutex_trylock and unlock.