I am developing a web application where I need to run a thread for 60 seconds which needs to check for response coming from a webservice. If the response arrives within 60 seconds I will forward to success othewise I will forward to a time out page after 60 seconds. I am using JSF 2.0?
I have thought of using the Timer but not sure whenther I can run the timer for sprcefic amount of time only.
Is there any smart solution for this ??
Do absolutely not use
Timerfor this! It’s funny for one-time-run desktop applications, but it has severe potential problems when used in a lifetime long running Java EE web application.Rather use the executors from the
java.util.concurrentpackage. Here’s a kickoff example: