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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T09:23:54+00:00 2026-06-16T09:23:54+00:00

I have two designs for an instant message program that I’m writting in Java

  • 0

I have two designs for an instant message program that I’m writting in Java

The first idea uses 2 separate threads. The first thread overlooks the gui and sends out the instant message data through writing to a blocking socket. The 2nd thread uses another blocking socket to monitor for incoming packets from the friend. I’m not certain if using threads is the best way to approach this problem, but I find it to be easier to deal with than using non-blocking socketchannels.

The 2nd design that I have is to use non-blocking socket channels in one thread which will occasionally check to see if there is incoming or outgoing data. The nice thing about this design is that I don’t have to worry about resource sharing among threads, but I’m not sure if its more efficient.

Honestly, all I really care about is making a program that runs smoothly and efficiently. What do you think would be a more efficient and easier design to build? I’m just playing around so I have no experience in building efficient and powerful client/server programs other than what my senses tell me.

  • 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-16T09:23:57+00:00Added an answer on June 16, 2026 at 9:23 am

    Long time ago I made a software, which had the chat module with TCP/IP : sockets.

    At the beginning for each client it was 2 Thread: the ReaderThread and the WriterThread. It wasn’t enough, because the clients get disconnected. I needed to make an InactivityChecker thread too, because the reader wasn’t able to detect disconnections at server side, and the writer only when he had message. 3 thread / client is a bit waste of the resources, but it can go up to 5000 simultaneous clients!! -it will eat your processors with context switching! Also has must take care of the maximum port numbers opened.

    If you would like to allow more than 65525/2 clients “simultaneously” for technical reasons the asynchron way is the only was to go.

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

Sidebar

Related Questions

In my vb program, I have two forms that work together to allow you
I have a design problem: I have two threads, a heartbeat/control thread and a
Have two folders with approx. 150 java property files. In a shell script, how
I have two designs for the UITableViewCells, one for the selected cells and other
I have two layouts for one activity like layout-port and layout-land, with different designs.
I have two tables: Designs and Urls. A Design can be related to many
Let suppose i have two html pages p1 & p2 and it uses different
I need a table City for my database model, I have two possible designs:
I have been working for two years in software industry. Some things that have
I'm thinking about a database design that will have two tables Members and Groups.

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.