That is multi-threaded issues, and these issues affects everything you make, so it's hardly fair to say that it's a design flaw for this specific piece of code. It wasn't made to be thread safe. Can it be done? Sure. But at a cost. If you don't need it to be thread-safe, or if you want the caller to make it thread-safe, then why implement such a protection at all when all it does is add overhead?

