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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:48:12+00:00 2026-05-24T08:48:12+00:00

I have an application (server side) that sits on a port and listens for

  • 0

I have an application (server side) that sits on a port and listens for client connections.
Once a connection is made, the app launches a parser (another thread) that deals with that connection.

My problem is that at some points (because the parsing can take long) the server app launches a new thread while other is being processed. This is a desired behavior, not a problem per se. what happens is that the new thread seems to read some state-variable from the old thread and therefore acts wrongly.

Loosely, what the parser does is this:
the client always sends two packets; the first is basically an knock knock packet and the second is the real data packet.
I read the first, and if i decide to accept it i put that in a variable, so that the next packet can be read.

On the scenario am describing, the first thread reads the knock knock packet and validates it.
The next packet arrives (on the same thread) and the parsing starts.

In the mean time, another parser is created and it waits for its first packet;
What then happens (the problem) is that it checks for the validation variable (which should be false for this thread) and it finds it to be ok (it reads from the previous thread, which is still executing) and proceeds to parse the knock knock packet as if it were the data packet.

What am lokoing for is a way to completely eliminate data sharing. am using the following class to keep track of the session state:

public class SessionInfo {

    private Constants.PacketValidity validity;
    private int packetSize;
    private String IMEI;
    private int packetReportedSize;
    private Constants.PacketType packetType;
    private int codec;
    private int records;
    private boolean valid;
    private Constants.ResponseType responseType;
    private String clientIP;
    private int serverPort;
    private Date parseInit;
    private Date parseEnd;
}

apart from that, the class has a bunch of setters and getters.

the parser has a instance of this object as a private field.

How would i achieve 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-05-24T08:48:13+00:00Added an answer on May 24, 2026 at 8:48 am

    the parser has a instance of this object as a private field.

    This is your problem. A solution would be to create a new SessionInfo and pass it as a method argument to the parser, passing it on to further method calls. Once you do this the reference to the session state will be local to the current thread execution.

    If your parser contains more private attributes that are updated during parsing, you need to extract these also. Combining them in a private subclass and creating an instance of that class when you are called to parse would be a possible solution to that problem.

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

Sidebar

Related Questions

I have a Silverlight application on the client communicating with the server side through
I have a client server application with multi-threading. The server side is failing with
I have a mission critical Perl-CGI server-side application that I need to extend or
I have got a Client/Server Application that using Asynchronous Socket.My problem is i cant
May i achieve that server side application (using android bluetooth API)connect to particular client
I have a web application that, like usual, is divided in two parts: server-side
I have a client / server application made with C#. Its working fine when
In my asp.net application I have a some client side scripting that alters the
I am writing a client-server application using Java-RMI. Some server-side ressources have to be
What tools for server side application performance testing you suggest? Have an application server

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.