package chatRoom; import java.io.DataOutputStream; import java.io.IOException; import java.net.Socket; public class ToOtherUserThread extends Thread { private Socket s; private Queue q; public ToOtherUserThread(Socket s, Queue q) { this.s = s; this.q = q; } public void run() { DataOutputStream outToServer = null; try { outToServer = new DataOutputStream(s.getOutputStream()); } catch (IOException e) { e.printStackTrace(); } String newMsg; while(true) { newMsg = q.take(); try { outToServer.writeBytes(newMsg + '\n'); } catch (IOException e) { e.printStackTrace(); } } } }