课程: C++ Development: Advanced Concepts, Lambda Expressions, and Best Practices

今天就学习课程吧!

今天就开通帐号,24,100 门业界名师课程任您挑!

Threads

Threads

- [Instructor] A thread is a unit of concurrency. In C++, the main function is the main thread of execution. Within the context of the operating system, the main thread runs concurrently with other threads owned by other processes. The standard thread class is the root of concurrency in the standard library. All other concurrency features are built upon the foundation of the thread class. This is thread.cpp from chapter six of the exercise files. You notice we have a couple of functions here. We have sleepms, which sleeps a given number of milliseconds. The argument that's passed to it is a number of milliseconds. We have a thread function. And this thread function loops a number of times. It loops five times, and each time it loops, it sleeps a certain number of milliseconds. And the milliseconds is 100 times the integer that's passed to the thread function. And down here in main, we passed the thread function of…

内容