• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Concurrency in a web application

 
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic