Possibly more convenient to use two `ThreadLocal<Boolean>`s.