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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:38:51+00:00 2026-05-23T11:38:51+00:00

I am working on a java server which dispatches xmpp messages and workers execute

  • 0

I am working on a java server which dispatches xmpp messages and workers execute the tasks from my clients.

private static ExecutorService threadpool = Executors.newCachedThreadPool();

DispatchWorker worker = new DispatchWorker(connection, packet);
threadpool.execute(worker);

Works fine, but i need a bit more than that.

  1. I don’t want to execute the same request multiple times.
  2. My worker may start another thread with a backround task also only allowed to run once at a time. A Threadpool in the worker threads.

I can identify the requests by a string and i can also give the backround tasks an id to identify them.

My solution would be a synchronized hashmap where my running tasks are registered with their id. The reference of the map will be passed to the worker threads that they remove their entry when they finished.

Feels a bit clumsy this solution so i wanted to know if there are more elegant patterns/best practices.

best regards, m

  • 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-23T11:38:52+00:00Added an answer on May 23, 2026 at 11:38 am

    This is exactly what Quartz does (although it does a lot more, like scheduling jobs in the future).

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

Sidebar

Related Questions

I'm working especially with Java web applications (in which mostly with JSF, Java Server
I have a Java server page which should execute showPeopleDetails function, when a user
I am working on a Java application which uses Servlets, an application server, JMS,
I'm working on a Java 6 application server which has a web service for
I'm working with a Java sort-of-application-server (Smartfox) which can run multiple applications (extensions) but
We have a Database in Sybase, which we access from a Java server. Access
I am working on a legacy Java Enterprise server project, trying to set up
I have been working in Java/J2ee projects, in which I follow the Maven structure.
Some code a production server which uploaded files has seemingly stopped working with the
Am working on an application which has a requirement to download bulk data from

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.