0

I am building my server side for an app and I am thinking if I should run each query or http request (or any other time consuming process) on a thread (java)?

What will happen if new process will step into the server side (say some request via servlet) and at the same time some time consuming process already running (query or http request)?

I am using java on apache tomcat server (maven).

Thanks!

vlio20
  • 8,955
  • 18
  • 95
  • 180
  • possible duplicate of [Can i spawn a thread from a servlet?](http://stackoverflow.com/questions/4836408/can-i-spawn-a-thread-from-a-servlet) – Kevin Panko Mar 16 '14 at 00:26

1 Answers1

1

all doGet methods of a certain servlet will be run automatically in different threads.

This what the Java Servlet Specification 3.0 says about Handling Request

The basic Servlet interface defines a service method for handling client requests. This method is called for each request that the servlet container routes to an instance of a servlet. The handling of concurrent requests to a Web application generally requires that the Web Developer design servlets that can deal with multiple threads executing within the service method at a particular time. Generally the Web container handles concurrent requests to the same servlet by concurrent execution of the service method on different threads.

Scary Wombat
  • 44,617
  • 6
  • 35
  • 64