public void initializeStreams() throws IOException { System.out.println("ThreadWorker# initialize start"); writer = new ObjectOutputStream((socket.getOutputStream())); writer.flush(); reader = new ObjectInputStream(new BufferedInputStream(socket.getInputStream())); System.out.println("ThreadWorker# initialize success"); }
public void sendMessage(ObjectExchange data) throws IOException { synchronized (this) { if (writer != null && !socket.isClosed()) { // data.friend_id = transactionId; writer.writeObject(data); writer.flush(); } } }