I have error in my applications server logs
SEVERE: A web application appears to have started a thread named [MyThread] but has failed to stop it. This is very likely to create a memory leak.
To resolve this i should stop the thread in contextDestroyed method of My ServletContextListener implementation.
But I am not able to understand how to get reference of my Thread/Runnable so that i can call interrupt().
One solution i have is : putting this thread instance in ServletContext attribute but not sure it is good practice or not. Please suggest if you follow some other approach in your application.