We will analyse such code
struct Bar {
void operator()() {
std::cout << "Hello world\n";
}
}
void foo() {
std::cout << "Hello world\n";
}
int main() {
std::thread t1(foo);
Bar bar;
std::thread t2(bar);
std::thread t3([]() {
std::cout << "Hello world\n";
});
t1.join();
t2.join();
t3.join();
}
void foo() {
std::cout << "Hello world\n";
}
class Bar {
public:
void foo() {
std::cout << "Hello world\n";
}
};
int main() {
std::thread t(&foo);
t.join();
Bar bar;
std::thread t1(&Bar::foo, &bar);
t1.join();
return 0;
}
Your abilities after Multithreading – threads training
-
know and use
std::threads
- can properly pass data between threads
- know and can resolve problems with lifetime and exceptions in threads
Agenda
-
std::thread
- parameter passing - Not-A-Thread
-
join()
vsdetach()
- problems - dangling references, exceptions
- data sharing - intro
- recap
Activities
- pre-work to be done before our training
- pre-test pre-test at the beginning
- exercises followed by trainers implementation
- coding dojo
- participants solutions code review
- post-work with code review
- post-test one week after the training
- certificate of completion
Duration
- 1 day (4 hours with breaks)
Form
- online
- classroom
Order Multithreading – threads training
Related trainings
Multithreading - atomic, conditional_variable, call_once
Other utilities from thread support library that are used with threads or asynchronous tasks