wood burning stoves 2.0*
The moose likes EJB and other Java EE Technologies and the fly likes Concurrency in a web application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Concurrency in a web application" Watch "Concurrency in a web application" New topic
Author

Concurrency in a web application

John Paterson
Ranch Hand

Joined: Mar 12, 2012
Posts: 121
Hi Folks,

I hope this is the correct section to post this as it's a query related to web based technologies. Let's say a person is developing an online booking system(could be movie booking, hotel room booking etc). How do you handle concurrecny for such an application? I mean issues like person B trying to book the same slot that person A is already in the process of booking. Does the web server (GlassFish,Tomcat,WebLogic etc) handle it 'automatically' where no intervention is required from the developer or does the developer actually need to write classes that implement the runnable interface or extend the thread class and use the synchronize keyword to lock the method? Please do advise. Thanks folks.

regards
John
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41085
    
  43
Depends on which web technology you use. Servlets are multi-threaded, so you'd need to write them in such a way that they're thread-safe. Most web frameworks (like Struts, Stripes etc.) implement an abstraction that is single-threaded, so that the developer need not worry about that (Struts Actions or Stripes ActionBeans).

As regards the DB, you should use transactions so that it can detect any conflicts and fail them with an exception if necessary.


Ping & DNS - my free Android networking tools app
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Concurrency in a web application
 
Similar Threads
JBoss and user threads and sockets
Questions on Sequence Diagrams
Why Swing client at all?
duties of Developer and Designer
Clarification