Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 767827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T18:05:13+00:00 2026-05-14T18:05:13+00:00

I have developed a simple server using Tomcat which runs a servlet. The servlet

  • 0

I have developed a simple server using Tomcat which runs a servlet.

The servlet calls a command line program – which takes about 20 seconds to execute then returns the result to the user via JSON. The problem is – if i make above 2 simultaneous requests, the servlet blocks until one of the previous requests is completed.

An example of this can be seen below – “Im in” is the top of the servlet, and the list of results is after the servlet is executed. All requests were made at the same time – but you can clearly see they are not dealt with simultaneously. What setting do I need to change in tomcat in order to have all requests handeled at the same time?

Im in 

Im in 

FVFNT01 STOP_IDLE FVFNT03 STOP_IDLE FVFNT16 STOP_IDLE FVFNT17 STOP_IDLE
FVFNT01 STOP_IDLE FVFNT03 STOP_IDLE FVFNT16 STOP_IDLE FVFNT17 STOP_IDLE
Im in

FVFNT01 STOP_IDLE FVFNT03 STOP_IDLE FVFNT16 STOP_IDLE FVFNT17 STOP_IDLE
Im in

FVFNT01 STOP_IDLE FVFNT03 STOP_IDLE FVFNT16 STOP_IDLE FVFNT17 STOP_IDLE
Im in

FVFNT01 STOP_IDLE FVFNT03 STOP_IDLE FVFNT16 STOP_IDLE FVFNT17 STOP_IDLE
Im in

FVFNT01 STOP_IDLE FVFNT03 STOP_IDLE FVFNT16 STOP_IDLE FVFNT17 STOP_IDLE
Im in

FVFNT01 STOP_IDLE FVFNT03 STOP_IDLE FVFNT16 STOP_IDLE FVFNT17 STOP_IDLE
Im in

FVFNT01 STOP_IDLE FVFNT03 STOP_IDLE FVFNT16 STOP_IDLE FVFNT17 STOP_IDLE
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T18:05:14+00:00Added an answer on May 14, 2026 at 6:05 pm

    Requests to servlets are handled concurrently by default. There is no setting that enables/disables this behaviour. This is confirmed by the JavaDoc for HttpServlet:

    Servlets typically run on
    multithreaded servers, so be aware
    that a servlet must handle concurrent
    requests and be careful to synchronize
    access to shared resources.

    However, if your servlet implements the marker interface SingleThreadModel, the servlet will only handle one request at-a-time. However, use of this interface is generally considered a bad practice, and because you didn’t mention it, I assume you’re not using it.

    Of course even if you’re not implementing SingleThreadModel you can make any servlet single-threaded using (probably inappropriate) synchronisation, e.g.

    class MyServlet extends HttpServlet {
    
      private void Object sharedObject = new Object()
    
      protected synchronized void doGet(HttpServletRequest req, HttpServletResponse resp) {
        // method logic goes here
      }
    
      protected void doPost(HttpServletRequest req, HttpServletResponse resp) {
    
        synchronized(sharedObject) {
          // method logic goes here
        }
    
      }
    
      protected void doPut(HttpServletRequest req, HttpServletResponse resp) {
    
        synchronized(this) {
          // method logic goes here
        }
      }
    }
    

    In the example above, only one thread may execute the same request method at-a-time, though it is possible (for example) for one thread to execute doPost() while another is executing doGet().

    If you don’t understand why this is, then I recommend you do some reading on concurrent programming in Java before investigating your problem further.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 376k
  • Answers 376k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Is enough to change the meta-data and title on my… May 14, 2026 at 8:32 pm
  • Editorial Team
    Editorial Team added an answer The Real-world Functional Programming book that I wrote with Jon… May 14, 2026 at 8:32 pm
  • Editorial Team
    Editorial Team added an answer A materialized view in SQL Server is always up to… May 14, 2026 at 8:32 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.