title: ThreadLocal performance vs using parameters
body: <p>I am currently implementing a runtime (i.e. a collection of functions) for a formulas language. Some formulas need a context to be passed to them and I created a class called EvaluationContext which contains all properties I need access to at runtime. </p>
  
  <p>Using <code>ThreadLocal&lt;EvaluationContext&gt;</code> seems like a good option to make this context available to the runtime functions. The other option is to pass the context as a parameter to the functions that need it.</p>
  
  <p>I prefer using ThreadLocal but I was wondering if there is any performance penalty as opposed to passing the evaluation context via method parameters.</p>