[undertow-dev] Cache object that is not thread safe

Steve Hu stevehu at gmail.com
Thu Apr 5 07:36:35 EDT 2018


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 at redhat.com> wrote:

> If you want one per thread just use ThreadLocal.
>
> Stuart
>
> On Thu, 5 Apr. 2018, 7:42 pm Steve Hu, <stevehu at 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 at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/undertow-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/undertow-dev/attachments/20180405/ecfa2c7f/attachment.html 


More information about the undertow-dev mailing list