Reputation: 80176
we have been using ThreadLocal so far to carry some data so as to not clutter the API. However below are some of issues of using thread local that which I dont like
1) over the years the data items being carried in thread local has increased 2) Since we started using threads (for some light weight processing), we have also migrating these data to the threads in the pool and copying them back again
I am thinking of using an in memory DB for these (we doesnt want to add this to the API). I wondering if this approach is good. What r the pros and cons.
ok here is a simple scenario
Upvotes: 0
Views: 1257
Reputation: 2288
you may want to introduce a request context: http://www.corej2eepatterns.com/Patterns2ndEd/ContextObject.htm
you can handle creation/destruction of such an object in a Filter if you're using a WebContainer or an Interceptor if you're using an ApplicationServer.
Upvotes: 1