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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:28:24+00:00 2026-06-10T00:28:24+00:00

I am currently learning how to program a tcp server in java. I am

  • 0

I am currently learning how to program a tcp server in java. I am creating a new thread for new each client connection (multithreaded server).

After the client connects to the server, I want to send data from the client to the server. On serverside the server is in a while loop reading data from the sockets inputstream. I want to ask now: Should I create a new thread for each received packet?

For example the client sends the string “Hello”. Should the server handle this packet in a new thread so it can continue reading, because I think if I don’t create a new thread, server doesn’t go back on reading and if client sends another packet after the “Hello” packet for example “Bye”, the server might not read it because it could still be busy handling the “Hello” packet.

To be clear I am not talking about serversockets accept method, I am talking about the data from sockets inputstream.

Please enlighten me about 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-10T00:28:25+00:00Added an answer on June 10, 2026 at 12:28 am

    If your packet handle task is not very heavy (probably it is not), you shouldn’t. Thread will handle a message and come back to receiving new messages. No data will be lost – if nobody reads from inputstream, data transfer just holds (after all buffers filled).
    Just keep one thread per client, it is enough in most cases.

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

Sidebar

Related Questions

I am currently learning how to program Java in android. I read various artices
So I am currently reading a book on learning java and a program outlined
im currently learning stacks in java and have a quick question. what will the
At school we are currently learning sorting algorithms in Java and I got for
I'm kind of new to the .NET platform. And currently I'm learning ASP.NET MVC.
I'm currently learning libgmp and to that end I'm writing a small program which
As I am currently learning C#, I made a small program to calculate X
I am currently learning objective c on my pc and my program will not
I'm currently learning Windows/DOS assembly. I'm just making a small program that adds two
I am currently in a Java class using Java: How to Program, Ninth Edition

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.