The problem with your code should be obvious if you think about what thread local means.You are initializing the thread local variables in the main thread, but using the thread locals in a separate thread. A thread local variable has a separate value for every thread. Therefore, the value you set in the main thread will never be visible to another thread.