The reason it hangs is that you're opening one connection to the server and keep sending data to it, but in the receiving end, you're discarding the first connection, and start waiting for the next connection to happen.
Either you can create a new connection from the sender every time you send data. The code block
Socket sender = new Socket("localhost", 8080);
PrintWriter pw = new PrintWriter(sender.getOutputStream(), true);
has to be moved inside the for loop. (of course, take care to release all resources)
OR,
fix the receiver to read data from the first connection, instead of waiting for a new connection for the second pack of data.