MENU

Fun & Interesting

Join And Detach In C++

CppNuts 73,247 lượt xem 5 years ago
Video Not Working? Fix It Now

JOIN ME
—————
YouTube 🎬 https://www.youtube.com/channel/UCs6sf4iRhhE875T1QjG3wPQ/join
Patreon 🚀 https://www.patreon.com/cppnuts

COMPLETE PLAYLIST
————————————
C++ Tutorial For Beginners: https://www.youtube.com/watch?v=3IynvwjrV-U&list=PLk6CEY9XxSIAQ2vE_Jb4Dbmum7UfQrXgt
STL (Standard Template Library): https://www.youtube.com/watch?v=LyGlTmaWEPs&list=PLk6CEY9XxSIA-xo3HRYC3M0Aitzdut7AA
ThreadIng In C++: https://www.youtube.com/watch?v=TPVH_coGAQs&list=PLk6CEY9XxSIAeK-EAh3hB4fgNvYkYmghp
Data Structures: https://www.youtube.com/watch?v=7tLVMUKLu2s&list=PLk6CEY9XxSIBG2Gv6-d1WE3Uxqx94o5B2
Algorithms: https://www.youtube.com/watch?v=4FxAK1tjLto&list=PLk6CEY9XxSICTSMyFM3GxRIwiZ7uqlJ9H
Design Patterns: https://www.youtube.com/watch?v=XyNWEWUSa5E&list=PLk6CEY9XxSIDZhQURp6d8Sgp-A0yKKDKV
Smart Pointers: https://www.youtube.com/watch?v=wUzn0HljjRE&list=PLk6CEY9XxSIAI2K-sxrKzzSyT6UZR5ObP
C++14: https://www.youtube.com/watch?v=1EAL_RRCKhY&list=PLk6CEY9XxSIAloDTEauOy_ss9fEqSP4JR
C++17: https://www.youtube.com/watch?v=aH7tYWjndgk&list=PLk6CEY9XxSIAEzHd_hTO-PRD6L8XfIUzu
C++ All Type Casts: https://www.youtube.com/watch?v=HlNVgmvX1EI&list=PLk6CEY9XxSIC6I_HCjMTGf8eV2Ty0a19E


INTERVIEW PLAYLIST
————————————
C++ Interview Q&A: https://www.youtube.com/watch?v=QSuBwGmFQqA&list=PLk6CEY9XxSIDy8qVHZV-Nf-r9f2BkRZ6p
C++ Interview Q&A For Experienced: https://www.youtube.com/watch?v=p2z7SJ5MWV8&list=PLk6CEY9XxSIDVpUt0yxC0b3IqDk63U7Bg
Linked List Interview Questions: https://www.youtube.com/watch?v=M5tQ4fJMsr0&list=PLk6CEY9XxSICJ0XSI7fbQFiEpDHISJxqT
BST Interview Questions: https://www.youtube.com/watch?v=RXeI7k9rhgE&list=PLk6CEY9XxSIAOYLZRHT20Zp3sPIbMzUNk
Array Interview Questions: https://www.youtube.com/watch?v=Z2TulQg5t30&list=PLk6CEY9XxSIDApw_RB8cowBQmzrznmpTA
String Interview Questions: https://www.youtube.com/watch?v=PnhL-c36JzM&list=PLk6CEY9XxSICY0vpYUdMlv-1Gk5CzuyQQ
Bit Manipulation Questions: https://www.youtube.com/watch?v=9CWVhu38a-Q&list=PLk6CEY9XxSIC5KqCCuaIVcuuFaXfAVWy8
Binary Tree Interview Question: https://www.youtube.com/watch?v=att1zpryvCw&list=PLk6CEY9XxSIAA3F1TVDoBTE0Lx-LZ5Ym6
Sorting Algorithms: https://www.youtube.com/watch?v=Vv-gs437i2g&list=PLk6CEY9XxSICqQ9wicEpRh3jYNTtSHVOy
C++ MCQ: https://www.youtube.com/watch?v=RJqS2JwlM6E&list=PLk6CEY9XxSIAr1ig2XzKJ1XS23Pn7SVnK
C MCQ: https://www.youtube.com/watch?v=yRzEGZ-QouU&list=PLk6CEY9XxSIBs60KjvhQMtjl1UjVcJC2E
C Interview Questions: https://www.youtube.com/watch?v=RQZ9DE4nUR4&list=PLk6CEY9XxSIB9jwcI0SP_FbamuqSWxvse

QUICK SHORT VIDEOS
————————————-
C++ Short : https://www.youtube.com/playlist?list=PLk6CEY9XxSIChg28m9UnVkPpfJobvlheb
C Short : https://www.youtube.com/playlist?list=PLk6CEY9XxSIAPNa21YdP5jcwaRgEfXF4-

In this video we will learn about what is the Use Of join(), detach() and joinable() In Thread In C++ (C++11)

JOIN NOTES
0. Once a thread is started we wait for this thread to finish by calling join() function on thread object.
1. Double join will result into program termination.
2. If needed we should check thread is joinable before joining. ( using joinable() function)

DETACH NOTES
0. This is used to detach newly created thread from the parent thread.
1. Always check before detaching a thread that it is joinable otherwise we may end up double detaching and
double detach() will result into program termination.
2. If we have detached thread and main function is returning then the detached thread execution is suspended.

NOTES:
Either join() or detach() should be called on thread object, otherwise during thread object�s destructor it will
terminate the program. Because inside destructor it checks if thread is still joinable? if yes then it terminates the program.

#threading #cpp #programming #tutorial #computerscience #softwareengineering

Comment