Exercise 3.38 - basic race condition stuff, just did it for completion