This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Struts and the fly likes Struts not multithreaded? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts not multithreaded?" Watch "Struts not multithreaded?" New topic
Author

Struts not multithreaded?

J.H.B. Oosterlaar
Ranch Hand

Joined: Sep 12, 2002
Posts: 41
Hi,
I was thinking. The Action dispatching is not multithreaded. In other words: the Action does nog extends Thread nor does it implements Runnable.
What is the reason for this? When there are many client requests, there will be a waitbuffer, won't there be? Request are handled after eachother.
Could anyone explain this? We are developing a dispatcher that dispatches jobs to actions that need to be Threads, because they extract data from the database. In order to not slowing down other requests, we made it an extension of Thread.
Thanks and cheers,
Jeroen Oosterlaar
David Weitzman
Ranch Hand

Joined: Jul 27, 2001
Posts: 1365
I don't know much about Struts, but from the Struts Javadocs:
Actions must be programmed in a thread-safe manner, because the controller will share the same instance for multiple simultaneous requests
corneliu mamut
Greenhorn

Joined: Oct 29, 2002
Posts: 4
Originally posted by J.H.B. Oosterlaar:
Hi,
I was thinking. The Action dispatching is not multithreaded. In other words: the Action does nog extends Thread nor does it implements Runnable.

You are right. But
public class ActionServlet
extends HttpServlet {
...
}
So the ActionServlet class is an servlet (multithreaded - the threads are managed by your servlet container). The execute() or perform() methods are called from ActionServlet (or your ActionServlet).
See also
http://www.javaranch.com/newsletter/Mar2002/newslettermar2002.jsp
[ March 20, 2003: Message edited by: corneliu mamut ]
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
Struts runs through servlets so multi-threading is not an issue.


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
J.H.B. Oosterlaar
Ranch Hand

Joined: Sep 12, 2002
Posts: 41
Thanks, I found out myself. Threads aren't even possible. Say I develop my own dispatcher. My actions are extensions of Thread. When I pass the request object to that action, it cannot be used anymore. The reference is lost. Thanks for the comments.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Struts not multithreaded?