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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T14:47:49+00:00 2026-06-05T14:47:49+00:00

I am new to Java NIO . I have a java program which queries

  • 0

I am new to Java NIO .

I have a java program which queries servers (different IPs /Ports) iteratively in a loop.
But now i want to send all the packets at once instead of in a loop and then store the data received in the reply packet.

The query consists of only 1 reply packet, no further communication is required.

is this the way to do it – >
Make a datagram Channel ,
send all packets via .send() ,
listen for packets and start new thread to process and store packet data.

number of servers maybe >400 .
Is it better to make 400 threads or 400 datagram channels ???
Also should i use async package instead of NIO .

Would it be easier with Netty etc?

  • 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-05T14:47:52+00:00Added an answer on June 5, 2026 at 2:47 pm

    I’m not familiar enough to advise of NIO, but regarding replies handling – better use thread pool and channel pool.

    EDIT – more explanation

    You should have just one thread that listens on the port to which the servers reply. Upon receiving a reply, submit a “handle task” to a tasks queue. The next available thread will pull that task and handle it.

    So, if you have more replies (=tasks) than available threads, the tasks will wait in the queue. Java has nice thread pool support under java.util.concurrent package. These limits are of course configurable.

    Basically, the listner thread is performing a minimal operation of creating a handle-task and putting in a queue. If you’re afraid of missing replies during that short period then you should configure more listener threads… But I doubt there’s a real concern there.

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

Sidebar

Related Questions

I am new to Java NIO.I have a small doubt. If I use the
I am new to java NIO. I have to write a simple server client
I have the following code adding an ActionListener to a JTextField: chatInput.addMouseListener(new java.awt.event.MouseAdapter() {
I have made a program that continuously monitors a log file. But I don't
I have written a Hello, world program with JNI. Java calls c program with
I want to use the new java.nio.file.Files.walkFileTree in Scala. And I was even successful:
I have question on usage java nio and hope someone who has a lot
In my implementation of Java NIO I have not been able to get SelectionKey.attach()
I'm creating a small server using java.nio , but when trying to stress test
I have been trying to work with NIO SocketChannels for some time now, and

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.