Added thread local storage to thread function.