views:

32

answers:

2

Hi all, if I have the following class, will I run into a problem if 100 people are requesting the page at the same time? If there is only one copy of UpdateUser, will all the requests have to queue up and wait for their turns? Thank you.

public static UserManager
{
     public static void UpdateUser(int UserID)
     {
          // this process takes up 2 seconds
          UserDataAccessor DA = new UserDataAccessor();
          DA.Update();
     }
}
A: 

It depends on what all your other code is doing, but that particular code will not cause any problems.

tster
A: 

In general, if you are writing a web application using Java servlets, you need to design your classes to allow for multiple threads. The application server you deploy your code into will call this one class many times, possibly simultaneously if there are many users at once. This is quite common.

The code you posted here looks fine. There are field variables being shared between threads. Each thread of execution will invoke your method and create a DA variable that is private to the thread.

Gary