Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

updating and using String in multiple threads

umassEngineerumassEngineer Posts: 1Member
Hello all,

I am attempting to create a basic chat program and I am having some difficulties as I am trying to use threads for it. There is a single Server object that listens for Client connects, and assigns each one to its own thread. The problem is that I'd like all threads to 'receive' any string generated by all clients, for outputting purposes.

Can I have an instance variable in my Server class that each thread can write to as well as outputting that variable if it has been outdated since last check, or is that just nonsense? A little new to threading here...

Thanks in advance,

-UE

Comments

  • djgaloredjgalore Posts: 56Member
    Your server needs to keep track of all connected clients. if it receives a message from any client then it needs to notify all other connected clients. You need something like a handler that will control/handle any client request/responses.
Sign In or Register to comment.