Is it possible to clear the ThreadLocal variables if a thread is handed back to pool after use in EAP?

Solution Verified - Updated -

Issue

  • If ThreadLocal variables are used to store application information across several (internal) invocations these can be left which might consume memory and also affects the next task which is handled by this Thread. Is there a way to clear it if handed back to pool, i.e. by a listerner for the ThreadPool?
  • ThreadLocals were not cleared when a thread was returned to the pool. Is there an option in EAP to clear them?
  • Is it possible to register a listener or somewhat to do customize the cleanup for a thread if handed back to pool?

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP)

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.