avoid using thread local storage for thread index