From the course: Parallel and Concurrent Programming with C++ Part 2
Unlock the full course today
Join today to access over 22,400 courses taught by industry experts or purchase this course individually.
Thread pool - C++ Tutorial
From the course: Parallel and Concurrent Programming with C++ Part 2
Thread pool
- After identifying the tasks in a program that can run asynchronously, one way to run those tasks in parallel is to create independent threads, or processes, for each of them. Preparing a basic salad requires us to chop lettuce and chop tomatoes. So, Olivia and I will act as independent threads to execute those tasks in parallel on our two processors, the knives. - A salad with just lettuce and tomatoes is so boring. We need something more. What about cucumbers? - Sure, chopping cucumbers is another task that can run asynchronously. So, we'll spawn another thread to handle that. Hey Barron. Hey Barron. - We need onions, too. What's up, Olivia? What's up? - Another task, another thread. - And mushrooms! - Again, another thread. - And carrots, and celery, and peppers, and an eggplant. - Whoa, whoa. It's getting crowded in here. We've got a lot of threads in the kitchen, but only two processors to…
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.