This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Servlets and the fly likes Can web apps be multi-threaded? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Can web apps be multi-threaded?" Watch "Can web apps be multi-threaded?" New topic

Can web apps be multi-threaded?

Robert Miller
Ranch Hand

Joined: Jun 18, 2004
Posts: 56
I'm studying servlets and JSP's and I was thinking about how they could be applied to a system I'm working with. The current system consists of one process which manages the state of the system, which serves user interface programs running in different processes. The processes communicate using a socket connection, with messages being sent when the state changes.

I've been wondering how I could put a web interface on this system. The problem is I would need an object running in a different thread to process the messages. I could create that object when the ServletContext is initialized and query it from within servlets. Is this a good idea? Is it even allowed? If not, can anyone suggest how I might do this?

danny liu
Ranch Hand

Joined: Jan 22, 2004
Posts: 185
It is allowed. However, when multiple requests share the same
resource, its methods must be sychronized.

jQuery in Action, 3rd edition
subject: Can web apps be multi-threaded?
It's not a secret anymore!