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

  • Home
  • SEARCH
  • 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 9060837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T15:20:02+00:00 2026-06-16T15:20:02+00:00

So I have worked with Multithreading in small application. Create a new thread here,

  • 0

So I have worked with Multithreading in small application. Create a new thread here, a new thread there.

I’m currently working on a program that monitors an IRC chat. For every valid command it creates a thread, does some work, and outputs the result to the chat. At times the application will get 10 or more valid commands in a short time and 10 or more threads are created. The application starts to really slow down. I’ve read that creating and closing threads is very cost inefficient with resources so I want to change my method.

An idea I’ve had is to create some threads (5 or so?) that are always running with a method that I pass commands to that queues them in a FIFO basis. Before I implemented this I wanted to see if there is something better I should be using. I don’t want to run off and reinvent the wheel, of course.

  • 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-16T15:20:04+00:00Added an answer on June 16, 2026 at 3:20 pm

    You can use a fixed size ExecutorService thread poll. Submit each message to send as a task and they will be sent as there is a free thread. e.g.

    ExecutorService es = Executors.newFixedThreadPool(5);
    

    Note: this can lead to messages being sent out of order so your client should be able to reorder the messages based on a timestamp.


    BTW: If 10 command at once is notably slow, it’s not the creating of threads which will be causing this. Threads are expensive yes, but not that expensive. Instead it is likely to network delays or some other blocking operation. You may need to create qa queue for each client if you have poor network connections.

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

Sidebar

Related Questions

I have a extension that uses multithreading using worker thread as shown here .
I have worked with Apache before, so I am aware that the default public
I have a worker thread that needs to add items to a BindingList .
I have worked through the answer provided here . I have been able to
I have worked on several distributed client/server projects recently, and one pain point that
I'm working on a simulation that uses multithreading extensively. The thing is that, until
I'm writing an application that listens on UDP for incoming messages. My main thread
I have worked on multithreading (in Qt) but i lack an in-depth knowledge. I
I have a C# application that uses a Windows service that is not always
i Have worked with normal gridview control,in my new project i have to use

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.