I was recently writing some code to implement a file system cache for streams and came across an interesting dilemma: how do I lock around a file that is being created by ThreadA until it is ready to be accessed by ThreadB? This is not a classic producer/consumer problem as you might be thinking: Any ...