You wrap it in a mutex and then it is allowed.
Global state is allowed. It just has to be thread safe.