-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathClientMultithreads.java
More file actions
33 lines (29 loc) · 1019 Bytes
/
ClientMultithreads.java
File metadata and controls
33 lines (29 loc) · 1019 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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();
}
}
}