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();

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-01-18
  • 2021-11-24
  • 2022-12-23
  • 2022-12-23
  • 2021-06-06
  • 2021-08-27
猜你喜欢
  • 2021-09-18
  • 2022-01-06
  • 2021-09-18
  • 2022-01-08
  • 2021-08-04
  • 2022-12-23
相关资源
相似解决方案