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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:47:16+00:00 2026-06-04T21:47:16+00:00

There is auction server which accepts clients and make for each socket connection a

  • 0

There is auction server which accepts clients and make for each socket connection a new thread to serve client. Each thread has it’s protocol. Server have only one instance of Auction object. Auction object holds list of Lot objects. Auction object is passed as argument to client thread. Protocol has to have a way to put a bid and notify all client threads somehow. The makeBid method exists in Lot and it puts bid to list of bids. The next step is to notify all client thread form makeBid method. What is the best practice to do this?
enter image description here

I tried to use a field (MSG) in Thread to hold a message. Thread checks if !MSG.isEmpty() while in run(). If !MSG.isEmpty() then ClientThread prints to socket this MSG. I think there is a better solution.


public class ClientServiceThread extends Thread  {
public String PRINT_NEW_MSG = "";
while (m_bRunThread) {

                if(!PRINT_NEW_MSG.isEmpty()){
                    out.println("PRINT_NEW_MSG: "+PRINT_NEW_MSG);
                    PRINT_NEW_MSG = "";
                String clientCommand = in.readLine();
                                 ...
            }
}
  • 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-04T21:47:17+00:00Added an answer on June 4, 2026 at 9:47 pm

    You could create a subscription design that calls a lotUpdated() method whenever a client places a bid on a Lot. Each ClientThread would subscribe to the Lots that it wants to be notified of.

    public class Lot {
      private List<ClientThread> clients = new ArrayList<ClientThread>();
      private List<Integer> bids = new ArrayList<Integer>();
    
      public synchronized void subscribe(ClientThread t){
        clients.add(t);
      }
    
      public synchronized void unsubscribe(ClientThread t){
        clients.remove(t);
      }
    
      public synchronized void makeBid(int i){
        bids.add(i);
        for (ClientThread client : clients){
          client.lotUpdated(this);
        }
      }
    }
    
    public ClientThread {
      public void lotUpdated(Lot lot){
        //called when someone places a bid on a Lot that this client subscribed to
        out.println("Lot updated");
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am making an auction website, which has an auto-bid system. This system lets
Is there any way to call an action script function from an anchor which
In the show action, there is logic that requires me to define: @object.nested_object.new (or
There is an action in the admin section of a client's site, say Admin::Analytics
A n-tier layer project. In businesslayer, there is a inherited Class Called BaseEdit which
I have an auction website which let my users place an unlimited amount of
The idea behind is a multiplayer browser game which interacts with a PHP server.
I have an MVC3 Razor view which has a link that requires user login
i, I have one Materialized view on one server which is created by DB
For my Java game server I send the Action ID of the packet which

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.