You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
for (Iterator<? extendsMap.Entry<TransmittableThreadLocal<?>, ?>> iterator = holder.get().entrySet().iterator();
iterator.hasNext(); ) {
Map.Entry<TransmittableThreadLocal<?>, ?> next = iterator.next();
TransmittableThreadLocal<?> threadLocal = next.getKey();
// backupbackup.put(threadLocal, threadLocal.get());
// clear the TTL values that is not in captured// avoid the extra TTL values after replay when run taskif (!capturedMap.containsKey(threadLocal)) {
iterator.remove();
threadLocal.superRemove();
}
}
如果直接用map,在capture 时清理map中的数据,同时在restore 清理map中的数据,会有什么影响?想了半小时,实在没想清楚在什么场景下,下面这代码的意义:
同时,在run 的 finally 中restore 的原因也没想明白, 如果线程结束了,那么 把之前的 TransmittableThreadLocal restore回来有什么意义? 线程复用的话,应该是在下次线程执行时复用 启动线程的 TransmittableThreadLocal,而不是restore 的TransmittableThreadLocal。
谢谢啦解答下。
The text was updated successfully, but these errors were encountered: