aspose file tools
The moose likes Servlets and the fly likes Threading Issues and Web applications Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "Threading Issues and Web applications" Watch "Threading Issues and Web applications" New topic
Author

Threading Issues and Web applications

faisal khan
Ranch Hand

Joined: Mar 13, 2002
Posts: 47
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

Joined: Mar 22, 2000
Posts: 12266
    
    1
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


Java Resources at www.wbrogden.com
faisal khan
Ranch Hand

Joined: Mar 13, 2002
Posts: 47

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

Joined: Jan 10, 2002
Posts: 56162
    
  13

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.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
 
I agree. Here's the link: jrebel
 
subject: Threading Issues and Web applications
 
Similar Threads
distributable element
Handling Threading Issue ???
HttpSessions getting mixed up
Inserting multiple rows at a time in the table?
Calling a web service in a Thread