Skip to content

Instantly share code, notes, and snippets.

@esibirtseva
Created March 17, 2015 11:10
Show Gist options
  • Save esibirtseva/52340406eb834402f093 to your computer and use it in GitHub Desktop.
Save esibirtseva/52340406eb834402f093 to your computer and use it in GitHub Desktop.
package alena.s21;
/**
* Created by Алена on 17.03.2015.
*/
import java.io.InputStream;
import java.io.OutputStream;
import java.io.IOException;
import java.net.Socket;
/**
*/
public class WorkerRunnable implements Runnable{
protected Socket clientSocket = null;
protected String serverText = null;
public WorkerRunnable(Socket clientSocket, String serverText) {
this.clientSocket = clientSocket;
this.serverText = serverText;
}
public void run() {
try {
InputStream input = clientSocket.getInputStream();
OutputStream output = clientSocket.getOutputStream();
long time = System.currentTimeMillis();
output.write(("HTTP/1.1 200 OK\n\nWorkerRunnable: " +
this.serverText + " - " +
time +
"").getBytes());
output.close();
input.close();
System.out.println("Request processed: " + time);
} catch (IOException e) {
//report exception somewhere.
e.printStackTrace();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment