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 8263245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T04:02:01+00:00 2026-06-08T04:02:01+00:00

I have completed the following Java Servlet construction: [I believe the main idea is

  • 0

I have completed the following Java Servlet construction: [I believe the main idea is that of consumer-producer]

  1. A Java servlet that receives multiple http POST requests

  2. It puts all requests into a Queue [ConcurrentLinkedQueue]

  3. All requests in the Queue are processed by a single and independent thread (like an engine). This thread works independently of the servlets.
    There is a good reason for the separate thread, since I need data from several and different http requests to do the processing. The Queue waits until it has enough requests and then starts the processing.

Now I’m in the final step: Once e.g. http request No1 has been processed by the independent thread engine, I need to notify the specific servlet thread (e.g. No1) where it came from so that I can reply, i.e. send the response back to the corresponding client.

How do I solve this threading issue? How can the single thread engine notify the correct servlet thread each time? How should I code this?

  • 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-06-08T04:02:02+00:00Added an answer on June 8, 2026 at 4:02 am

    I don’t know where are these requirements coming from, but there are several other, much simpler approaches to this problem:

    • Use ExecutorService. Simply submit a task to the pool and block on returned Future object. Very simple and effective. Once your task is ready, Future.get() will return the result

    • With Servlet 3.0 you can put whole processing in asynchronous thread. This is much more scalable. Basically you are submitting a task and releasing HTTP thread immediately. The asynchronous thread does not only process items in that queue but also returning HTTP response via AsyncContext object.

    If you really need to use a queue and a separate thread, have a look at Java locks and conditions. But that’s much more low-level work.

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

Sidebar

Related Questions

I have the following code in Main.java : public class Main extends Activity implements
I have following command that runs on Windows: java -classpath lib/prov-jdk14-132.jar;../EncUtility com.xxxx.projects.disc.bowl.FileChooseApp Now I
I am following this tutorial https://developer.android.com/guide/tutorials/views/hello-tabwidget.html and have completed it. Now I would actually
I have the following: <%= f.select :phase_names, options_for_select([RFP Stage, Pre Contract, Awarded, Unsuccessful, Completed]),
I have a storyboard like the following Duration=0:0:1 Completed=DeviceExplorer_Completed> The animation for some reason
I have completed my program and would like to send that program in its
I am trying to complete the tutorial at http://www.ajaxprojects.com/ajax/tutorialdetails.php?itemid=438 It seems that the servlet
I have recently completed the following interview exercise: 'A robot can be programmed to
I have a java class that applies an xslt to all xml files in
I have read that generally abstract classes should not be made Serializable in Java.

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.