I am trying to implement a client-server application. Suppose i have two files, Server.java
and Client.java
. I am connected with both via DataOutputStream
and DatainputStream
and through socket programming. The clients have multi-threading implemented in Server.java.
Now the Server.java is doing a write.utf()
to write a question to the Client.java, and the Client.java, in its terminal, is implementing a readUTF()
and uses the Scanner
class to get input from user keyboard.
Suppose now there is another client thread that wants to broadcast a message to all other clients. How would i stop/pause/lock the Scanner
in the Client console to do a writeUTF()
to the Client console to broadcast the message? The client should be able to resume its activity after the message is broadcasted.