Search code examples
javamultithreadingjakarta-eedaemon

Is it relevant to run a Thread in Context Listner in J2EE?


I want to design a process which will always run in background. So I write a Thread class and write the process in infinite loop in run method. I know running a thread in J2EE not right practice. But any how I want continuous process in background. Is it right or what else I can do?


Solution

  • There is no restriction that is documented. As long as you can control the threads (for example you do not create one every request) and you gracefully shut them down, my experience is that it does not create any issues.