im trying to create a multi-threading connection by creating a new thread that will allow the client to send and receive messages. the issue im facing is all the errors that are displayed within my code and im unsure where to start and how to establish this code to conduct an actual connection. Thank you anyone that does come across and help.
package sendmessage;
Thread SendMessage = new Thread(new Runnable() {
@Override
public void run() {
while (true) {
// read the message to deliver.
String msg = sc.nextLine();
try {
// write on the output stream
dos.writeUTF(msg);
} catch (IOException e) {
e.printStackTrace();
}
}
}
});
package readmessage;
Thread ReadMessage = new Thread(new Runnable() {
@Override
public void run() {
while (true) {
try {
// read the message sent to this client
String msg = dis.readUTF();
System.out.println(msg);
} catch (IOException e) {
e.printStackTrace();
}
}
}
});