How to use join method to wait for threads to finish?
If you want a thread to work until another thread dies, you can join the thread onto the end of the another thread using the
join() method. For example, you want thread
B only work until thread
A completes its work, then you want thread
B to join thread