代码之家  ›  专栏  ›  技术社区  ›  FoxyBOA

所有线程的Java ThreadLocal转储值[重复]

  •  0
  • FoxyBOA  · 技术社区  · 7 年前

    上下文:

    static ThreadLocal<MyType> 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...]
    }
    
    0 回复  |  直到 15 年前