There is no general answer to this.

There are following common options:

- Deny request until the first is finished:

  static Boolean cMutex = new Boolean(true);
  static boolean cRunning = false;



  // in the method that performs the processing
  synchronized (cMutex) {
     if (cRunning) {
       // return [error]message
     } else {
       cRunning = true;
     }
  }
  try {
    // Do what ever has to be done
  } finally {
    cRunning = false;
  }  

  (Just one approach, there are several others)

- Serialize Requests

  synchronized void doSomething() {
       // Do what ever has to be done
  }

- Stop the first request
  Depending on the code that you want to perform for
  the request this can get very tricky.

- run them multi threaded
  To do that your code must be thread safe,
  and your database code must be designed in a way
  that the threads will not lock each other. What
  you have to do to achieve this, depends on you own 
  code and the locking strategy of the database. 
  (Wether it has Table-, Page- or Row- locking)

> -----Ursprüngliche Nachricht-----
> Von: Michael Nicholson [mailto:[EMAIL PROTECTED]]
> Gesendet: Donnerstag, 10. Oktober 2002 17:53
> An: Tomcat Users List
> Betreff: OT: How to handle requests in quick sessions / 
> possible thread
> issue
> 
> So, I now have an Oracle backend that's supposed to be 
> accessed by jsps and servlets.  Which works.  However, if a 
> user gets impatient (I know, it never happens, but just in 
> case!), then while the database is doing it's thing, the java 
> process receives a new request and starts a new thread, 
> right?  But this is a problem in that it stops responding.  
> Entirely.  I don't know if this means that my db connection 
> got closed midway through the second process (which should 
> now have the request and response instances that my browser 
> wants back), and therefore it's sitting there going "which 
> way did it go, which way did it go" (you have to imagine the 
> silly cartoon voice), or what.  And I don't really know that 
> connection pooling will help.
> 

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to