0

Why thread join is needed after blocking call of future.get

Hi If I am not wrong , we need to join thread object so that main thread wait for thread to get completed. Without doing so, exit will be bad exit. Also, future.get() is a blocking call and will wait until thread function is completed. With these two statement , I thought we don't need to join thread if we have used future.get(). Is this correct? If not , why? If yes, why below code has issue if I comment t.join() line in main function? https://sololearn.com/compiler-playground/cFn1Tvsfe4dm/?ref=app

25th Sep 2024, 11:55 AM
Ketan Lalcheta
Ketan Lalcheta - avatar
4 Answers
+ 2
get does not handle cleanup.
25th Sep 2024, 12:42 PM
Bob_Li
Bob_Li - avatar
+ 1
the thread object have to be destructed. it have to be joined for it to happen.
25th Sep 2024, 3:12 PM
Bob_Li
Bob_Li - avatar
0
Sounds good. What actually cleanup does? Just curious to know. Is it relayed to pcb (process control board) data management taken care by OS?
25th Sep 2024, 2:50 PM
Ketan Lalcheta
Ketan Lalcheta - avatar