Breaking of Program Invariants

This lesson explains challenges related to the breaking of program invariants during the implementation of concurrency in C++.

Program invariants are invariants that should hold for the entire lifetime of your program.

Malicious race condition breaks an invariant of the program. The invariant of the following program is that the sum of all balances should be the same amount. In our case, this is 200 euros because each account starts with 100 euro (line 9). I neither want to create money by transferring it nor do I want to destroy it.

Get hands-on with 1400+ tech skills courses.