Thread join and lock example enhanced