Thread Joining
To wait for spawned threads to finish their execution before exiting from main, we can join the thread handle.
Joining waits for the target thread to finish and returns its result or indicates if the thread panicked.
To wait for spawned threads to finish their execution before exiting from main, we can join the thread handle.
Joining waits for the target thread to finish and returns its result or indicates if the thread panicked.