class OtherAppNotifier implements Runnable {
public void run() {
... doe something...
}
}
In your servlet:
doGet() {
processUserRequest();
new Thread(new OtherAppNotifier()).start();
}
You can also use java.util.TimerTask or some other threadpool thing if this
spawns too many threads. But try the simple case first to make it working
before optimizing it.
Ronald.
Op maandag, 23 augustus 2010 16:11 schreef Wesley Acheson
<wesley.ache...@gmail.com>:
Hi,
As far as I'm aware your not supposed to extend Thread in JEE. I've
seen similar questions on Stack Overflow where it was suggested you
may use your containers Thread pool. This sounds like a terrible idea
for portability.
So take the following example.
1 A request for something specific is made to tomcat. That specific
request needs to two actions.
2 Process the users request.
3 Notify another application over http
Now If the notification fails in step 3 the users request still needs
to process and not to error so we would like to send the notification
as a background task. This is pretty easy with Threads but we
shouldn't extend Thread according to the specifications.
Questions:
1 Should this be delegated to the container?
2 If it should be delegated to the container how would I/we achieve
this in tomcat 6.
3 If it shouldn't be delegated to the container where should I ask how
to achieve a background task, because it isn't a tomcat question.
(Disclaimer: If you really want to give me the answer I won't mind :P
)
Regards,
Wesley
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org