i is not using thread local storage. It is stored on the stack which means the values no longer exist when the function exits. Thread local storage has to explicitly be used. It is never implicit. So that observation has nothing to do with thread local storage. Please explain what you mean by "interlocking" the button.