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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:37:21+00:00 2026-06-11T15:37:21+00:00

For my program I was using a ConcurrentHashMap to hold references to multiple running

  • 0

For my program I was using a ConcurrentHashMap to hold references to multiple running objects.
In my server i have:

public class Server {

private ConcurrentHashMap<String, ChatRoom> _chatRooms;
private ExecutorService _chatRoomExecutor;
...

// create a new channel executor to handle 50 chatrooms
_chatRoomExecutor= Executors.newFixedThreadPool(50);
// create an admin chatroom for testing at this point
_chatRooms.put("/admin", new Channel("/admin"));
// execute that chatroom
_chatRoomExecutor.execute(_chatRooms.get("/admin"));

would this work as I could still access the chatroom from the ConcurrentHashMap or would I have to do something with the threadpool?

  • 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-11T15:37:22+00:00Added an answer on June 11, 2026 at 3:37 pm

    would this work as I could still access the chatroom from the ConcurrentHashMap or would I have to do something with the threadpool?

    Yes your code should work fine. However, you need to make sure that you are properly synchronizing on the fields in your ChatRoom objects since they will be accessed both from their run() method by the thread-pool threads as well as from the outside thread(s) by getting the objects from the ConcurrentHashMap. That’s going to be your challenge.

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

Sidebar

Related Questions

I have simple chat program using WCF service. One service use for server and
I have a program using odac(11.2) and oracle client 11.2. Now I want to
When running a java program using the java command you can specify the verbose
When programming an OO program using a SQL database back-end, do objects' attributes correspond
I have a c# program using WPF. I have it that when you press
I have a program using 3 header files and 3 .cpp files in addition
I have an OpenGL-program using GLSL, that I can run just fine with the
Consider the following C# program: using System; using System.Diagnostics; namespace Test { class MainClass
I have program using gtkmm, gtkglextmm and exiv2. I want to include these libraries
I have written a program using Free Pascal and the Lazarus IDE. In brief,

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.