• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Thread programming in a Struts application

 
Roger Jam
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi... Can we use Java Threads in a struts web application as we do in a stand Alone application. As all the control would be under Web/Application Server , it is efficient/allowable to induce threads in a struts web application . Please Suggest.
 
Mohana Rao Sv
Ranch Hand
Posts: 485
Eclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which struts version you were using?
What do you want to do with threads / why do you need it actually?
 
Joe Ess
Bartender
Pie
Posts: 9266
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Spawning threads is discouraged because it is safer to allow the container to manage threads. Have a look at this discussion for some alternatives.
 
Roger Jam
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Mohan and Joe..thanks for your suggestions. Sorry i was not able to get back here after posting. My requirement was to send a request to data base after some update is done depending on a condition.Client wants this to be independent. He wants to proceed to other links without depending on this operation result or time . I thought of using threads,but i didnt get any assured/suitable information whether i can use threads or any other alternatives. My application is struts based and we are using JBOSS server.Please suggest.
 
Joe Ess
Bartender
Pie
Posts: 9266
10
Linux Mac OS X Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One strategy I've used is to use a JMS queue to communicate with a stand-alone process. The request just has to place all the required information on the queue. The JMS queue is useful because it can queue up requests should the stand-alone process fail at any time. The stand-alone process reads from the queue, executes whatever processing it has to do then it sends an email with the report as an attachment.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic