This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Threading Issues and Web applications  RSS feed

 
faisal khan
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
kindly shares views regarding handling threading issues during Web application devlopment.

Following are the areas that developer should think?

1)Session Object handling.
2)Database handling.
3)Using non synchronized Java data structures like ArrayList VS Vector
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1)Session Object handling.
** Remember that although a given session is tied to a browser by the unique ID, the browser may make multiple requests "at the same time" so you can NOT rely on thread-safe handling of session objects.
2)Database handling.
** Use a DB connection pool, don't keep DB connections as session objects or instance objects.
3)Using non synchronized Java data structures like ArrayList VS Vector
** Depends entirely on the program architecture, no generalization possible.
Bill
 
faisal khan
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

ok fine now tell me if i use DAO classes for database,
and they are locally created in servlet doGet or doPost, are they thread safe or not.

another i dont understand session handling is also not thread safe?

regards
Faisal
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Once you realize that multiple instances of the same servlet can be executed simultanously in separate threads, all of your question becomes no different that dealing with threading issues elsewhere.

So, automatic variables that you create inside your servlet methods are safe as they are created on the thread's stack.

Read/write session access is not safe as multiple threads can be accessing the same structures simultaneously.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!