Best way to Synchronize Threads/Lock variables in a nontrivial computation

If the first and second functions do not mutate shared buffers, then the only part that needs a lock is the if ... end block.

1 Like