This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Can web apps be multi-threaded?  RSS feed

 
Robert Miller
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?

Thanks!
 
danny liu
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is allowed. However, when multiple requests share the same
resource, its methods must be sychronized.

Dan
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!