Thread Joining

Added code to handle thread parent relations