From the course: Complete Guide to Parallel and Concurrent Programming with C++
Unlock this course with a free trial
Join today to access over 24,800 courses taught by industry experts.
Detached thread - C++ Tutorial
From the course: Complete Guide to Parallel and Concurrent Programming with C++
Detached thread
- We often create threads to provide some sort of service or perform a periodic task in support of the main program. A common example of that is garbage collection. A garbage collector is a form of automatic memory management that runs in the background and attempts to reclaim garbage or memory that's no longer being used by the program. Many languages include garbage collection as a standard part of their runtime environment. But for this demonstration, I'll spawn my own new thread to handle garbage collection. - Man, what a mess. - Olivia is a separate child thread that will execute independently of my main thread so I can continue doing what I'm doing here, getting my soup ingredients ready. - Well, I try to reclaim some memory, or counter space, by clearing up Baron's garbage. - This setup with Olivia running as a separate thread to provide that garbage collection service will work fine until I'm ready to finish executing. Bam, now my soup spiced and ready. My main thread is done…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
Thread versus process4m 36s
-
Thread versus process: C++ demo6m 11s
-
(Locked)
Concurrent versus parallel execution4m 54s
-
(Locked)
Execution scheduling3m 38s
-
(Locked)
Execution scheduling: C++ demo2m 27s
-
(Locked)
Thread life cycle3m 35s
-
(Locked)
Thread life cycle: C++ demo4m 29s
-
(Locked)
Detached thread2m 49s
-
(Locked)
Detached thread: C++ demo1m 52s
-
-
-
-
-
-
-
-
-
-
-