











java:
public class JForumExecutionContext { private static ThreadLocal userData = new ThreadLocal(); /** * Gets the execution context. * @return JForumExecutionContext */ public static JForumExecutionContext get() { JForumExecutionContext ex = (JForumExecutionContext)userData.get(); if (ex == null) { ex = new JForumExecutionContext(); userData.set(ex); } return ex; } /** * Checks if there is an execution context already set * @return <code>true</code> if there is an execution context * @see #get() */ public static boolean exists() { return (userData.get() != null); } }
C#:
[ThreadStatic] private static Object StaticObject = new Object();
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。