Thanks. This is another option to explore. The question was asked on behalf of another user on another forum. I am going to find more info about the use case. Will pass your answers to him. 

On Thu, Apr 5, 2018, 7:50 AM Bill O'Neil, <bill@dartalley.com> wrote:
If it's actually a util object can you make it stateless so that it is thread safe? Maybe add an additional context type object for state if you really need it. Attaching it to the exchange as an attachment could work.

On Thu, Apr 5, 2018 at 7:36 AM, Steve Hu <stevehu@gmail.com> wrote:
I was thinking about ThreadLocal as it is very popular in Java EE but one request might be handled by multiple threads from IO thread to worker thread which means you have to instantiate as many objects as the number of total threads. Just trying to find if there are any better solutions. Thanks for your confirmation. 

On Thu, Apr 5, 2018 at 7:19 AM, Stuart Douglas <sdouglas@redhat.com> wrote:
If you want one per thread just use ThreadLocal.

Stuart

On Thu, 5 Apr. 2018, 7:42 pm Steve Hu, <stevehu@gmail.com> wrote:
I need to share the same instance of a "Util" object to reuse it in all the handleRequest calls. Where is the best place to store the Util object instance? The Util class is not thread safe, so I should have one instance for each client thread.

Thanks,

Steve

_______________________________________________
undertow-dev mailing list
undertow-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/undertow-dev


_______________________________________________
undertow-dev mailing list
undertow-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/undertow-dev