Uses thread-safe global variable.