Tag: 线程线程局部

有没有办法迭代或复制Java ThreadLocal的所有值?

语境: static ThreadLocal threadLocalMyType = … 我想要的是说: for (ThreadLocalEntry e: threadLocalMyType.getMapLikeThing() { // Thread t = e.getKey(); // I don’t need the thread value right now, but it might be useful for // something else. MyType theMyType = e.getValue(); // […do something with theMyType…] }