CST 334 - Week 5
This week, I learned about multi-thread code. Threads are helpful because they exist under a process and share the same virtual address. This way it does not have to start up another process and allows for concurrency. Concurrency offers benefits such as an IDE handling edits while background compilation is occurring. With this comes some risks of poor execution that could lead to problems. The critical section is where both threads run a code, meaning that piece of code accesses a shared resource. It is important to understand that two threads should not run at the same time in this section. Mutual exclusion is a condition that can help with this, by ensuring that at most, only one thread will be within a critical section at a time. The race condition is when the output of a multi-threaded program depends on the relative speed or scheduling of the thread. It is something that should be avoided because it means there is a lack of consistency on the output of the program. Ens...