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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T13:37:42+00:00 2026-06-04T13:37:42+00:00

I am implementing simple version of TCP, but lack of multi-thread technique. The main

  • 0

I am implementing simple version of TCP, but lack of multi-thread technique. The main thread controls 2 sub threads:

1. timer(counting down time, if timeout, inform main thread to do some job again)

2. listening incoming packet, loop forever. if packet is received, then update some data in main thread

The main thread should take action when a certain signal occurs.

I have no experience with event handling and design some signal to inform main thread.
Where should I start? For example, the sub thread updates main thread private field. Or should I create some event?

Here’s some pseudo code for the main thread:

while(true){
  event: send data ,then ...
  event: timeout , then send packet again
  event: packet received, then update data in private filed 
}
  • 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-04T13:37:44+00:00Added an answer on June 4, 2026 at 1:37 pm

    If you are new to the concept of multithreading in Java, I suggest reading this tutorial first: http://docs.oracle.com/javase/tutorial/essential/concurrency/

    Discussing your specific issue, you should have two threads:
    – one for listening to your socket, which will extend thread. It should receive a reference to your main object at construction time and keep listening to your socket. When something arrives, this thread will call the treatment routine for the main object to take action. Be careful only with busy waiting – yield for some time while socket is not ready.
    – your timer could be an extension of TimerTask. have a look at http://www.cloudhadoop.com/2012/01/timers-in-java-create-timer-in-java.html in order to understand more.

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

Sidebar

Related Questions

I am implementing a simple version of a linux shell in c. I have
Hey all, so I'm implementing the simple version of the discrete fourier transform in
Short version: Is there an attractive, simple way of implementing a language-specific url structure,
Implementing a simple Login screen using JSF and Spring and Hibernate. I have written
I'm implementing a simple Graph library for my uni project and since this is
I'm implementing a simple update mechanism for an application I'm writing the last part
I'm implementing a simple load balancer - it's an http listener which parses incoming
I am implementing a simple iOS solitaire game that allows the user to drag
Ok...... I'm implementing a simple OpenGL ES application on the iPhone and I recently
Web-development novice here. I want to try implementing a simple web site that uses

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.