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?

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();
...
}
}
You could create a subscription design that calls a
lotUpdated()method whenever a client places a bid on a Lot. EachClientThreadwould subscribe to theLotsthat it wants to be notified of.