adding lecture 28

This commit is contained in:
Jidong Xiao
2023-12-07 15:41:45 -05:00
parent 17201ce9ae
commit 7748af9d95

View File

@@ -143,6 +143,7 @@ private:
function (student thread, in this example). We pass the necessary shared data from the main thread to the function (student thread, in this example). We pass the necessary shared data from the main thread to the
secondary thread to facilitate communication. secondary thread to facilitate communication.
```cpp
#define num_notes 10 #define num_notes 10
void student_thread(Chalkboard *chalkboard) { void student_thread(Chalkboard *chalkboard) {
Student student(chalkboard); Student student(chalkboard);
@@ -160,6 +161,8 @@ int main() {
} }
student.join(); student.join();
} }
```
- The join command pauses to wait for the secondary thread to finish computation before continuing with the - The join command pauses to wait for the secondary thread to finish computation before continuing with the
program (or exiting in this example). program (or exiting in this example).
- What can still go wrong? How can we fix it? - What can still go wrong? How can we fix it?