From the course: Complete Guide to Parallel and Concurrent Programming with C++
Unlock this course with a free trial
Join today to access over 25,300 courses taught by industry experts.
Thread life cycle - C++ Tutorial
From the course: Complete Guide to Parallel and Concurrent Programming with C++
Thread life cycle
- When a new process or program begins running, it will start with just one thread, which is called the main thread, because it's the main one that runs when the program begins. That main thread can then start or spawn additional threads to help out, referred to as its child threads, which are part of the same process, but execute independently to do other tasks. Those threads can spawn their own children if needed, and as each of those threads finish executing, they'll notify their parent and terminate with the main thread, usually being the last to finish execution. Over the life cycle of a thread, from creation through execution, and finally, termination, threads will usually be in one of four states. If I'm the main thread in this kitchen and I spawn or create another thread to help me, that child thread will begin in the new state. - Hello. - This thread isn't actually running yet, so it doesn't take any CPU resources. - I don't even know what I'm supposed to be doing. - Part of…
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
-
-
-
-
-
-
-
-
-
-
-